Skip to content

docs: record the 0-d array return of scalar indexing in the 3.0 migra… - #4694

Open
RafaelPulzi wants to merge 1 commit into
zarr-developers:mainfrom
RafaelPulzi:docs-v3-migration-scalar-indexing
Open

RafaelPulzi wants to merge 1 commit into
zarr-developers:mainfrom
RafaelPulzi:docs-v3-migration-scalar-indexing

Conversation

@RafaelPulzi

Copy link
Copy Markdown

The migration guide doesn't mention what happened to scalar indexing. Indexing a single element returned a NumPy scalar in Zarr-Python 2 and returns a 0-dimensional numpy.ndarray in Zarr-Python 3, which is what the Python array API standard specifies for getitem. Arrays whose shape is () went the other way: reading one gave a 0-d array in v2 and gives a scalar in v3. Right now the only place either behaviour shows up is the Array.getitem doctest.

This adds item 4 to "The Array class" with both directions and the two ways to get a scalar back, item() and [()], plus a link to the standard's getitem page. Nothing outside the docs changed.

Refs #3741 rather than closing it: that issue also asks whether getitem should return something different, which is a separate decision.

…tion guide

Scalar indexing returned a NumPy scalar in Zarr-Python 2 and returns a
0-dimensional numpy.ndarray in Zarr-Python 3, following the Python array
API standard. Arrays whose shape is () changed in the other direction.
The migration guide covered neither, so the change was only visible from
the Array.__getitem__ doctest.
@d-v-b

d-v-b commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

thank you!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants