Conversation
Chunk specifications were parsed by `normalize_chunks_nd`, but a separate duck-typed classifier, `_is_rectilinear_chunks`, ran on the raw input first at three sites to decide whether the spec was rectilinear. Two opinions on the same input is the shape of the bug in zarr-developers#4374, and they could disagree: a 0-d numpy array counted as rectilinear because it has `__iter__`. The classifier is gone. Each site normalizes first and asks the resulting `ChunkGrid` (`is_regular`); stored rectilinear metadata passed as `chunks=` counts as rectilinear even when its edges are uniform. The shard resolver sends regular and rectilinear shard specs through the same normalizer. Also fixed on the way: - The legacy v2 branch of `AsyncArray.create` tested `chunks or chunk_shape`, so `zarr.create(chunks=np.array([...]), zarr_format=2)` failed with "truth value of an array is ambiguous". It now uses the `is not None` form the v3 branch already had. - 0-d numpy arrays unwrap to their scalar in both normalizers instead of failing with "len() of unsized object". - A non-integer scalar spec (`2.0`, `np.float64`) raises the normalizer's own TypeError instead of "object has no len()". Assisted-by: ClaudeCode:claude-fable-5-1
Assisted-by: ClaudeCode:claude-fable-5-1
Documentation build overview
7 files changed ·
|
Documentation build overview
26 files changed ·
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4376 +/- ##
==========================================
- Coverage 94.34% 94.22% -0.12%
==========================================
Files 92 92
Lines 12935 12932 -3
==========================================
- Hits 12203 12185 -18
- Misses 732 747 +15
🚀 New features to boost your workflow:
|
d-v-b
force-pushed
the
fix/single-chunk-normalizer
branch
from
September 18, 2026 17:00
22d828c to
9d0f413
Compare
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.
🤖 AI text below 🤖
Follow-up to #4374 / #4375, asking whether there is a single, correct function from user input (
chunks=) to a chunk grid configuration.What was there
The parser is
normalize_chunks_nd→normalize_chunks_1d, and it already handled numpy scalars (numbers.Integral) and numpy arrays (iterated, elements coerced withint()) correctly at every entry point. But it was not the only logic on the path: a separate duck-typed classifier,_is_rectilinear_chunks, ran on the raw input at three sites (AsyncArray.create,init_array,resolve_outer_and_inner_chunks) to decide whether the spec was rectilinear, so the v2 and sharding policy errors could fire. Two opinions on the same input is the shape of the bug in #4374, and they could disagree (a 0-d numpy array counted as rectilinear because it has__iter__).Changes
_is_rectilinear_chunksis deleted. Each site normalizes first and asks theChunkGrid(is_regular); storedRectilinearChunkGridMetadatapassed aschunks=still counts as rectilinear even when its edges are uniform. The shard resolver sends regular and rectilinear shard specs through the same normalizer.AsyncArray.createdidchunks or chunk_shape, sozarr.create(chunks=np.array([5, 3]), zarr_format=2)failed with "truth value of an array is ambiguous". It now uses theis not Noneform the v3 branch already had.2.0,np.float64(2.0)) raises the normalizer's ownTypeError(was "object has no len()").Tests
-1) × three creation paths (create_arrayv3,create_arrayv2, legacycreatev2), asserting the stored chunks are plain ints.(2, np.array([3, 3])), 2-D arrays, edges of numpy ints) produce the expectedRectilinearChunkGridMetadata.shards=.test_mixed_chunks_gates_are_order_independent,test_pipeline_sharding_rejects_rectilinear_chunks_with_shards) still pass against the normalized-grid check.Not changed:
Trueis still accepted as chunk size 1 (boolisIntegral); flagging rather than deciding that here.🤖 Generated with Claude Code