You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
numpy 2.0: a possible API inconsistency in numpy.ndarray.astype (copy semantics) ? #25925
As I'm adapting astropy to the new copy semantics from #25168 and #25922, I observe that numpy.ndarray.astype wasn't updated to follow these changes. As a result, it still supports the old semantics where copy=False means "copy only if you must" but never raises an error. Is that intended ?
numpy.astype, introduced in #25079, is also affected by this question.
Activity
rgommers commentedon Mar 4, 2024
@neutrinoceros thanks for the question. Yes, this was intentional, since there wasn't too much appetite for changing the behavior of
copy=Falsegiven thatastypeexplicitly casts to a different dtype - and that usually cannot be done without a copy. It's noted in NEP 56: https://numpy.org/neps/nep-0056-array-api-main-namespace.html#copy-keyword-semantics.I checked that
astypedoes accept all ofTrue/False/None.Falsejust doesn't mean "never copy". Does that seem reasonable?neutrinoceros commentedon Mar 4, 2024
Absolutely ! Just wanted to check with you before the first release candidate if I could :)
Let's just close this then. Good luck with the release !