[Numpy-discussion] asanyarray vs. asarray
njs at pobox.com
Fri Oct 19 18:40:10 EDT 2018
On Fri, Oct 19, 2018 at 3:28 PM, Ralf Gommers <ralf.gommers at gmail.com>
> On Fri, Oct 19, 2018 at 4:15 PM Hameer Abbasi <einstein.edison at gmail.com>
>> On Friday, Oct 19, 2018 at 6:09 PM, Stephan Hoyer <shoyer at gmail.com>
>> I don't think it makes much sense to change NumPy's existing usage of
>> asarray() to asanyarray() unless we add subok=True arguments (which default
>> to False). But this ends up cluttering NumPy's public API, which is also
>> Agreed so far.
> I'm not sure I agree. "subok" is very unpythonic; the average numpy
> library function should work fine for a well-behaved subclass (i.e. most
> things out there except np.matrix).
Masked arrays also tend to break code that's not expecting them (e.g. on a
masked array, arr.sum()/arr.size will silently compute some meaningless
nonsense instead of the mean, and there are lots of formulas out there that
have some similarities with 'mean'). And people do all kinds of weird
things in third-party array subclasses.
Obviously we can't remove asanyarray or break existing code that assumes
particular numpy functions use asanyarray, but fundamentally asanyarray is
just not an API that makes sense or can be supported in a general way, and
our overall goal is to get people to gradually transition away from using
ndarray subclasses in general. That's why we're doing all this work to make
duck arrays work. So extending asanyarray support doesn't seem like a good
priority to spend our limited resources on, to me.
Nathaniel J. Smith -- https://vorpus.org <http://vorpus.org>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion