Skip to content

feat(array): add Array.dimension_names property - #4401

Open
d-v-b wants to merge 5 commits into
zarr-developers:mainfrom
d-v-b:feat/array-dimension-names
Open

d-v-b wants to merge 5 commits into
zarr-developers:mainfrom
d-v-b:feat/array-dimension-names

Conversation

@d-v-b

@d-v-b d-v-b commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds a .dimension_names attribute to Array. It's None for V2 arrays, and metadata.dimension_names for v3 arrays. Closes #3595.

🤖 AI text below 🤖

Closes #3595.

Until now, dimension names could only be read through array.metadata.dimension_names, and only for Zarr format 3 arrays, because ArrayV2Metadata had no such attribute. As agreed in the issue, the new property returns None for Zarr format 2 arrays, which matches the v3 spec's meaning of an absent dimension_names.

Changes

  • ArrayV2Metadata.dimension_names: a property that always returns None. This mirrors the existing ArrayV2Metadata.shards, so code can read the attribute from either metadata version.
  • AsyncArray.dimension_names and Array.dimension_names: properties that return the metadata's value, typed tuple[str | None, ...] | None.
  • from_array now takes the source's dimension names from data.dimension_names, instead of reading metadata.dimension_names only when the source is format 3. Behavior is unchanged: a format 2 source gives None either way.

Tests

test_array_dimension_names covers v2 arrays, v3 arrays without names, with names, and with some names left as None. It checks the sync and async properties and that the names are the same after reopening the array.

I ran the full suite locally: 10813 passed.

🤖 Generated with Claude Code

Dimension names were only reachable through `array.metadata.dimension_names`,
and only for Zarr format 3, because `ArrayV2Metadata` had no such attribute.
Add a `dimension_names` property to `ArrayV2Metadata` that always returns
None, following `shards`, and expose it on `AsyncArray` and `Array`.
`from_array` now reads the property instead of branching on the format.

Closes zarr-developers#3595

Assisted-by: ClaudeCode:claude-opus-5-5
Assisted-by: ClaudeCode:claude-opus-5-5
@github-actions github-actions Bot added needs release notes Automatically applied to PRs which haven't added release notes and removed needs release notes Automatically applied to PRs which haven't added release notes labels Sep 24, 2026
Link the dimension_names section of the v3 core spec from the
Array.dimension_names and AsyncArray.dimension_names docstrings, and
test that duplicate names round-trip.

Assisted-by: ClaudeCode:claude-opus-5-5
@d-v-b
d-v-b marked this pull request as ready for review September 24, 2026 11:44
@codecov

codecov Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.37%. Comparing base (156cc04) to head (d452b41).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4401   +/-   ##
=======================================
  Coverage   94.37%   94.37%           
=======================================
  Files          93       93           
  Lines       13171    13180    +9     
=======================================
+ Hits        12430    12439    +9     
  Misses        741      741           
Files with missing lines Coverage Δ
src/zarr/core/array.py 98.10% <100.00%> (+0.01%) ⬆️
src/zarr/core/metadata/v2.py 89.56% <100.00%> (+0.17%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@d-v-b

d-v-b commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

I'm requesting review because this adds public API

@maxrjones maxrjones left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this addition. Thanks, Davis.

@d-v-b d-v-b added this to the 3.5.0 milestone Sep 27, 2026

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.

Array.dimension_names property

2 participants