Repository navigation
Conversation
Add `zarr_metadata.testing.strategies`, behind a new `testing` extra.
It ships Hypothesis strategies that draw valid Zarr v3 metadata fields,
one for every codec, data type, chunk grid and chunk key encoding the
package defines that holds no other field.
- Each kind's strategy takes what its configurations depend on: a data
type's fill values take its configuration, a chunk grid takes the
array shape, and a codec takes the `Chunk` it is handed.
- `fields` draws every envelope spelling the spec allows, or only the
canonical one.
- Strategies are a mapping keyed by definition, so an extension author
can add strategies for their own definitions.
The tests read every draw back in `CORE_AND_EXTENSIONS` and require no
problems. They also check:
- that every definition in scope has a strategy, apart from the three
that hold nested fields;
- reach, with targets derived from each configuration's TypedDict:
each optional key present and absent, each `Literal` value, and a
non-canonical spelling where one exists;
- fill-value spellings and envelope forms.
Strategies follow the spec where the package is looser. Core data types
are drawn only as bare strings, and regular-grid chunk lengths are never
zero ("Chunk sizes must be greater than zero"), although the package's
rules accept both today.
Assisted-by: ClaudeCode:claude-opus-5-5
…414 Assisted-by: ClaudeCode:claude-opus-5-5
This branch has not been deployed
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 🤖
Added
zarr_metadata.testing.strategies, Hypothesis strategies that draw valid Zarr v3 metadata fields, behind a newtestingextra (pip install zarr-metadata[testing]). There is one strategy for every codec, data type, chunk grid and chunk key encoding the package defines that holds no other field.fieldsdraws every envelope spelling the spec allows, or only the canonical one withspellings="canonical". Codecs can be drawn for theChunkthey are handed, chunk grids for an array shape, and fill values for a data type. The strategies are a mapping keyed by definition, so an extension author can add strategies for their own definitions.Tests
The agent added these tests in
tests/testing/test_strategies.py:sharding_indexed,cast_valueandstruct, which hold other fields and come in a follow-up.canonicalize. Fill values fit their data type, chunk grids fit their shape, and codecs either take their chunk or are refused by their rules.find, each test checks that every optional key appears present and absent, and that everyLiteralvalue, envelope form and fill-value spelling is drawn.LookupError,TypeErrorand the twoValueErrors.To check the tests, the agent planted 12 bugs in the strategies (for example dropping uppercase hex, never writing a run as a pair, or drawing a zero chunk length). The suite catches all 12.
Where the strategies follow the spec rather than the package
{"name": "int8"}.regular.py's rules accept 0.The agent did not change either validator.
Stack
This is the first of five planned PRs:
transition, and strategies forsharding_indexed,cast_value,structand rectilinear grids.zarr.🤖 Generated with Claude Code