fix: allow writing to 0-dimensional arrays with sharding#3966
Open
NIK-TIGER-BILL wants to merge 1 commit into
Open
fix: allow writing to 0-dimensional arrays with sharding#3966NIK-TIGER-BILL wants to merge 1 commit into
NIK-TIGER-BILL wants to merge 1 commit into
Conversation
Signed-off-by: NIK-TIGER-BILL <nik.tiger.bill@github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3966 +/- ##
==========================================
- Coverage 93.27% 93.24% -0.04%
==========================================
Files 87 87
Lines 11739 11746 +7
==========================================
+ Hits 10950 10952 +2
- Misses 789 794 +5
🚀 New features to boost your workflow:
|
chuckwondo
suggested changes
May 12, 2026
Contributor
chuckwondo
left a comment
There was a problem hiding this comment.
Thanks @NIK-TIGER-BILL!
Would you mind also adding a test that covers your patch that handles the 0D case? The test you added shows that the original case no longer errors, but that case no longer enters the function that you patched, so your patch itself remains untested, hence the failed codecov run.
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.
Closes #3751
This PR fixes a bug where writing to a 0-dimensional array with sharding enabled would crash with an
IndexErrorin the sharding codec's vectorized chunk slice lookup.The root cause was that
get_chunk_slices_vectorizedinzarr/codecs/sharding.pyassumedoffsets_and_lengthswas at least 2-dimensional, but for 0-dimensional arrays it has shape(2,)instead of(1, 2). This causedoffsets_and_lengths[:, 0]to fail with "too many indices for array".Fix: Add an early return in
get_chunk_slices_vectorizedto handle the 0-dimensional case by reshapingoffsets_and_lengthsto(1, 2)before slicing.Test: Added
test_sharding_zero_dimensionalintests/test_codecs/test_sharding.pyas a regression test.