Closed
Description
This is odd, it works as expected for the .nonzero
method, but not for the np.nonzero
function:
>>> np.__version__
'1.20.2'
>>> x = np.array(3)
>>> x.ndim
0
>>> np.nonzero(x)
(array([0]),)
>>> x.nonzero()
<ipython-input-5-68292516afaf>:1: DeprecationWarning: Calling nonzero on 0d arrays is deprecated, as it behaves surprisingly. Use `atleast_1d(arr).nonzero()` if the old behavior was intended.
x.nonzero()
(array([0]),)
I haven't looked into why this happens.
The deprecation happened in 1.17.0, see gh-13708.