-
-
Notifications
You must be signed in to change notification settings - Fork 12k
Description
Moving from #25922, which added this to the docs:
NumPy will pass
copyto the__array__special method in situations where
it would be set to a non-default value (e.g. in a call to
np.asarray(some_object, copy=False)). Currently, if an
unexpected keyword argument error is raised after this, NumPy will print a
warning and re-try without thecopykeyword argument. Implementations of
objects implementing the__array__protocol should accept acopykeyword
argument with the same meaning as when passed tonumpy.arrayor
numpy.asarray.
Thinking through how to update some __array__ implementations, I am wondering: what are the expectations from numpy how an __array__ implementations handles this keyword fully or partially?
When copy=True is being passed, does numpy assume that the __array__ implementation already made that copy? But what if the implementation defers dtype casting to numpy (which is currently possible), then it might be a waste to already copy up front?
Originally posted by @jorisvandenbossche in #25922 (comment)