Fix save/load for scalar arrays#4103
Merged
d-v-b merged 1 commit intoJun 26, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4103 +/- ##
=======================================
Coverage 93.50% 93.50%
=======================================
Files 90 90
Lines 11981 11981
=======================================
Hits 11203 11203
Misses 778 778
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3469.
save_array()andload()usedslice(None)as the full-array selection. That works for arrays with at least one dimension, but for 0-dimensional arrays it is interpreted as one index and raisesIndexError: too many indices for array; expected 0, got 1.This changes both paths to use
Ellipsis, which still means full-array selection for N-dimensional arrays and normalizes to an empty selection for scalar arrays. The regression test coversGroup.__setitem__with both an integer scalar array and a bytes scalar array, then verifies direct indexing andzarr.load().TODO:
docs/user-guide/*.mdchanges/Local verification:
uv run --frozen pytest tests/test_api.py::test_group_setitem_loads_scalar_arrays -quv run --frozen pytest tests/test_api.py::test_save tests/test_api.py::test_load_array tests/test_api.py::test_load_local tests/test_api.py::test_load_zip -quv run --frozen ruff check src/zarr/api/asynchronous.py tests/test_api.pyuv run --frozen ruff format --check src/zarr/api/asynchronous.py tests/test_api.pyuv run --frozen python -m compileall -q src/zarr/api/asynchronous.py tests/test_api.pygit diff --check