[Numpy-discussion] Scalar result for field access -- Fix in minor release?

Sebastian Berg sebastian at sipsolutions.net
Thu Dec 19 12:26:02 EST 2013


fixing a corner case indexing regression in 1.8, I noticed/fixed
accidentally this behavior of returning a scalar when indexing a 0-d
array with fields (see also [1]):

arr = np.array((1,), dtype=[('a', 'f8')])

arr['a']   # Returns an array
arr[['a']] # Currently returns a *scalar*

I think no field access should try to convert 0-d arrays to scalars, and
it was probably just an oversight. However, if anyone thinks there is
even the slightest chance that this creates bugs in production code, we
certainly should not change it in a bug-fix only release.

Or am I missing something and the old behavior was actually intended?

- Sebastian

[1] https://github.com/numpy/numpy/issues/4109

More information about the NumPy-Discussion mailing list