-
-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Description
Proposed new feature or change:
This may come too late, but numpy 2.0 may be a good opportunity to remove an irritating wart, that ufunc(array_scalar_arguments) returns a numpy scalar rather than an array scalar. There is a very long-standing PR (#14489) that introduces an option to avoid this (using out=...), but perhaps it is time to just ditch the conversion to scalar?
See gh-13105 for discussion. As a specific example of why it is unhandy, it mentions:
#13100 raises a case where
np.fixresorts to callingnp.asanyarray(np.ceil(x, out=out))in order to ensure that the result is an array. Unfortunately, this has a number of draw-backs:
- It discards duck-types, like
daskarrays- It changes the dtype of 0d object arrays containing array-likes
The first comment on the issue by @rgommers suggests just removing the cast to scalar. To me, this still makes the most sense.
EDIT: the simplest implementation of this is to not use PyArray_Return in ufuncs, or perhaps adjust PyArray_Return to remove the try of converting to scalars altogether.