-
-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Closed as not planned
Description
0d arrays are a special case for ufuncs. Indeed, rather than returning a 0d array, ufuncs return scalars in case of a 0d array inputs.
For example
print np.exp(np.array(1.0)).__class__returns <type 'numpy.float64'>, while
print np.exp(np.array([1.0, 2.0])).__class__returns <type 'numpy.ndarray'>.
Ideally ufuncs should return 0d arrays in case of 0d array inputs, and scalars in case of scalar inputs. (array>scalar) returns an array in every cases except in the case of a 0d array, which in my opinion breaks the Zen of Python.
One of the consequences of the behavior was that x[x>0] was giving an error in the case of 0d-arrays, which was solved by PR #3798 by allowing scalar boolean to be used as an index for 0d array.