-
-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Closed
Description
Proposed new feature or change:
The Array API standard says that np.nonzero should throw an exception for 0D input.
Currently, np.nonzero implicitly makes 0D input a 1D (with atleast_1d), no warning is raised a warning is raised. In its docstring it says:
.. deprecated:: 1.17.0
Use `atleast_1d` explicitly if this behavior is deliberate.
Also np.array(1).nonzero() gives a deprecation warning:
DeprecationWarning: Calling nonzero on 0d arrays is deprecated, as it behaves surprisingly. Use `atleast_1d(arr).nonzero()` if the old behavior was intended.
Do we want to throw an exception on 0D input for both cases for Array API compatibility?