-
-
Notifications
You must be signed in to change notification settings - Fork 450
fix(chunk-grids): make array creation O(1) in per-dimension chunk count #4218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
d-v-b
wants to merge
16
commits into
zarr-developers:main
Choose a base branch
from
d-v-b:claude/optimistic-diffie-2ef839
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
9e9ee4e
fix(chunk-grids): make array creation O(1) in per-dimension chunk count
d-v-b bf1a243
refactor(chunk-grids): drop dead ndarray branch from is_regular_1d
d-v-b 3b277af
test(metadata): cover the unknown-dimension-type guard in create_chun…
d-v-b d3c5c17
fix(testing): pass bare-int rectilinear dims through the chunks= conv…
d-v-b 535fa0a
fix(chunk-grids): keep explicit per-chunk lists rectilinear
d-v-b ed26f62
fix(array): guard chunks/shards access by stored grid kind, not runti…
d-v-b da2cff2
Merge branch 'main' into claude/optimistic-diffie-2ef839
d-v-b 79873b8
fix(array): make from_array 'keep' faithful for every stored chunk grid
d-v-b ad3a922
fix(array): coherent introspection for rectilinear-sharded arrays
d-v-b f88d2b2
Merge branch 'main' into claude/optimistic-diffie-2ef839
d-v-b 1258e94
Merge branch 'main' into claude/optimistic-diffie-2ef839
d-v-b 24cd91f
Merge branch 'main' into claude/optimistic-diffie-2ef839
d-v-b b88830e
fix(array): preserve stored grids verbatim through from_array 'keep',…
d-v-b 43e623f
Merge remote-tracking branch 'origin/claude/optimistic-diffie-2ef839'…
d-v-b dc84e7b
refactor+docs: apply ilan-gold's review suggestions
d-v-b 9b14db0
Merge branch 'main' into claude/optimistic-diffie-2ef839
d-v-b File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| Array creation is now O(1) in the number of chunks per dimension. Chunk | ||
| normalization returns a `ChunkGrid` whose uniform dimensions are stored as a | ||
| size + extent pair (`FixedDimension`) instead of being expanded to one entry | ||
| per chunk, so creating arrays like | ||
| `zarr.create_array(store, shape=(2**62,), chunks=(1,), dtype='int32')` succeeds | ||
| instantly instead of raising `ValueError` or allocating gigabytes of memory. | ||
| The intermediate `ChunksTuple` representation was removed in the process, and | ||
| `ChunksLike` now admits per-dimension specs that mix a bare int (uniform chunk | ||
| size) with explicit edge-length sequences, matching what the normalizer and | ||
| the rectilinear grid spec already accepted. | ||
| This fixes the array-creation half of #4174; the coordinate-selection | ||
| allocation reported there is still tracked in that issue (#4172 fixed the | ||
| related case of sorted 1-D coordinate selections). |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| Explicit per-chunk size lists now always produce a rectilinear chunk grid, | ||
| even when the sizes happen to describe a regular grid (all equal, or all equal | ||
| with a smaller trailing chunk). Previously such input was silently collapsed to | ||
| a regular grid, which changed resize semantics: a regular grid grows by | ||
| extending the uniform pattern, while a rectilinear grid appends a new edge | ||
| chunk — the behavior an append-oriented layout like `(168,) * 13 + (24,)` | ||
| relies on. The grid kind now follows the input syntax, matching 3.2.x: | ||
| scalar chunk sizes (including numpy integers and the `-1` sentinel) produce a | ||
| regular grid, nested sequences produce a rectilinear grid. Rectilinear grids | ||
| remain gated behind `zarr.config.set({"array.rectilinear_chunks": True})`. | ||
| See #4174 for the accompanying O(1) chunk normalization change. | ||
|
|
||
| `zarr.from_array` with the default `chunks="keep"` / `shards="keep"` now | ||
| reproduces the source's stored grid exactly: a rectilinear grid is passed | ||
| through in O(number of dimensions), with uniform dimensions keeping their | ||
| bare-int shorthand; sharding under a rectilinear shard grid is preserved | ||
| instead of being silently dropped; and the default `write_data=True` copy | ||
| works for every grid kind. `Array.chunks` is now defined for any sharded array | ||
| (the inner chunks of a shard are always regular), and for sharded arrays with | ||
| a rectilinear shard grid `Array.info` no longer raises — it reports the shard | ||
| shape as `<variable>` — while `Array.nchunks_initialized` counts the chunks of | ||
| each initialized shard individually instead of raising. | ||
|
|
||
| Everything described here concerns rectilinear chunk grids, which remain an | ||
| experimental feature gated behind | ||
| `zarr.config.set({"array.rectilinear_chunks": True})`; arrays with regular | ||
| chunk grids are unaffected. | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be clear, this is actually gated behind the feature flag, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but IMO we should consider removing the feature flag and making it on by default soon