Open numpy-gitbot opened 12 years ago
Original ticket http://projects.scipy.org/numpy/ticket/2120 on 2012-04-29 by atmention:njsmith, assigned to unknown.
Currently, this idiom works for all arrays that have ndim >= 1:
for i in xrange(np.prod(a.shape)): idx = np.unravel_index(i, a.shape) a[idx] = ...
(Obviously there are usually better ways to do this, but anyway.)
But, it fails for 0-d arrays:
>>> np.unravel_index(0, ()) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: dims must have at least one value
This should just return (), which is the unique index that can be used with 0-d arrays.
Original ticket http://projects.scipy.org/numpy/ticket/2120 on 2012-04-29 by atmention:njsmith, assigned to unknown.
Currently, this idiom works for all arrays that have ndim >= 1:
(Obviously there are usually better ways to do this, but anyway.)
But, it fails for 0-d arrays:
This should just return (), which is the unique index that can be used with 0-d arrays.