fix: let open_like create arrays by default#4146
Open
goutamadwant wants to merge 1 commit into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4146 +/- ##
=======================================
Coverage 93.84% 93.84%
=======================================
Files 91 91
Lines 12570 12572 +2
=======================================
+ Hits 11796 11798 +2
Misses 774 774
🚀 New features to boost your workflow:
|
Contributor
|
looks good, thanks for fixing this. requested changes
|
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.
Summary
Closes #3352.
zarr.api.asynchronous.open_likeis intended to create or open a persistent array using metadata copied from an existing array. When callers omittedmode, or passedmode=None, it delegated toopen_arraywithout a create-capable mode and raisedArrayNotFoundErrorfor a missing target path.This changes
open_likeso an omitted orNonemode defaults to"a"before delegating toopen_array. Explicit modes are still passed through unchanged.The regression test covers both Zarr v2 and v3, with
modeomitted and withmode=None.For reviewers
The main behavior choice is defaulting only
open_liketo append/create mode. I leftopen_arrayunchanged so this stays focused on the helper whose purpose is to create a similar persistent array.Verified with:
uv run pytest -q tests/test_api.py::test_open_like_creates_array_by_default tests/test_api.py::test_array_like_creation --tb=shortuv run pytest -q tests/test_api.py --tb=shortuvx prek run --files src/zarr/api/asynchronous.py tests/test_api.py changes/3352.bugfix.mdAuthor attestation
AI coding assistance is welcome, but a human must be the author and is responsible for the contents of the PR. The description and any review responses must be in your own words. Please read AI-assisted contributions before opening.
TODO
docs/user-guide/*.md- N/A, bug fix onlychanges/