refactor(sharding): store chunks_per_shard explicitly in _ShardIndex#3975
Open
d-v-b wants to merge 5 commits into
Open
refactor(sharding): store chunks_per_shard explicitly in _ShardIndex#3975d-v-b wants to merge 5 commits into
d-v-b wants to merge 5 commits into
Conversation
_ShardIndex previously inferred the chunk grid shape from offsets_and_lengths.shape[:-1]. For 0-D arrays this collapses the array to rank-1, breaking methods that assume rank >= 2 and forcing a numpy compat cast workaround. Store chunks_per_shard as an explicit NamedTuple field instead. This removes the chunks_per_shard property and its cast, and lets several call sites use the field directly instead of reverse-engineering it. Also fix a latent 0-D bug in is_dense, which iterated offsets_and_lengths assuming rank-2. Closes zarr-developers#3974 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3975 +/- ##
==========================================
- Coverage 93.29% 93.29% -0.01%
==========================================
Files 87 87
Lines 11752 11744 -8
==========================================
- Hits 10964 10956 -8
Misses 788 788
🚀 New features to boost your workflow:
|
_ShardIndex previously inferred the chunk grid shape from offsets_and_lengths.shape[:-1]. For 0-D arrays this collapses the array to rank-1, breaking methods that assume rank >= 2 and forcing a numpy compat cast workaround. Store chunks_per_shard as an explicit NamedTuple field instead. This removes the chunks_per_shard property and its cast, and lets several call sites use the field directly instead of reverse-engineering it. Also fix a latent 0-D bug in is_dense, which iterated offsets_and_lengths assuming rank-2. Tests for get_chunk_slices_vectorized, _ShardReader.__iter__, and is_dense are parametrized over chunk grid ranks (0-D, 1-D, 2-D) so 0-D is exercised as a normal case rather than a special branch. Closes zarr-developers#3974 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… chunk-index-tweak
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.
_ShardIndex previously inferred the chunk grid shape from
offsets_and_lengths.shape[:-1]. For 0-D arrays this collapses the array
to rank-1, breaking methods that assume rank >= 2 and forcing a numpy
compat cast workaround.
Store chunks_per_shard as an explicit NamedTuple field instead. This
removes the chunks_per_shard property and its cast, and lets several
call sites use the field directly instead of reverse-engineering it.
Also fix a latent 0-D bug in is_dense, which iterated offsets_and_lengths
assuming rank-2.
Closes #3974
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com