You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inconsistent () indexing/size behavior from v2->v3 #2713
Previously something like z[()] where z is a () shape array would return a scalar and now returns a one-elem array e.g., np.array(1) instead of np.float64(1.0)
The semantics of [:] is "select everything in the first dimension". I think since we have 0 dimensions this is expected to fail because there is no first dimension.
The semantics of [:] is "select everything in the first dimension". I think since we have 0 dimensions this is expected to fail because there is no first dimension
Do we want to return scalars when accessing zero-dimensional arrays? This would mean that the return value of __getitem__ is no longer NDArrayLike and may make typing more difficult
Activity
[-]Inconsisten `()` indexing/size behavior from v2->v3[/-][+]Inconsistent `()` indexing/size behavior from v2->v3[/+]jhamman commentedon Jan 15, 2025
Thanks @ilan-gold for the report. Looks like we missed the
()indexer in #2583brokkoli71 commentedon Jan 15, 2025
I'll take a look at it.
regarding your comment in:
z["bar"][...] = np.array(1) # why doesn't [:] work?The semantics of
[:]is "select everything in the first dimension". I think since we have 0 dimensions this is expected to fail because there is no first dimension.ilan-gold commentedon Jan 16, 2025
Makes sense!
brokkoli71 commentedon Jan 16, 2025
Do we want to return scalars when accessing zero-dimensional arrays? This would mean that the return value of
__getitem__is no longer NDArrayLike and may make typing more difficultdstansby commentedon Jan 16, 2025
Returning a scalar here would be consistent with numpy (2.2.1):