Skip to content

feat(zarr-metadata): draw nested fields and codec pipelines - #4597

Merged
d-v-b merged 10 commits into
zarr-developers:mainfrom
d-v-b:claude/zarr-metadata-nested-strategies
Nov 4, 2026
Merged

d-v-b merged 10 commits into
zarr-developers:mainfrom
d-v-b:claude/zarr-metadata-nested-strategies

Conversation

@d-v-b

@d-v-b d-v-b commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds strategies to zarr_metadata.testing.strategies for definitions that nest other stuff, namely struct, cast_value and sharding_indexed. Adds a new pipelines strategy for the Chunk abstraction.

Author attestation

  • I am a human, these are my changes, and I have reviewed and understood every change and can explain why each is correct.

TODO

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/user-guide/*.md
  • Changes documented as a new file in changes/
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

@github-actions github-actions Bot added needs release notes Automatically applied to PRs which haven't added release notes zarr-metadata Specific to the zarr-metadata sub-package labels Nov 3, 2026
d-v-b added 5 commits November 3, 2026 22:15
Add Hypothesis strategies for struct, cast_value and sharding_indexed,
which draw the fields they hold from the same Strategies mapping, and a
`pipelines` strategy that walks a codec pipeline, drawing each codec for
the chunk the codec before it hands on via its definition's transition.
A shard's inner and index pipelines are drawn for the chunks its
definition's `pipelines` gives. Shards and structs nest at most one
level deep, and strategies are wrapped in a mapping with a short repr so
Hypothesis's error notes stay under its 30,000-character warning.

Every strategy record's functions now take the Strategies mapping as
their last argument.

Assisted-by: ClaudeCode:claude-opus-5-5
`NOT_NUMBERS` predates the zarr-python data types, so `cast_value` and
`scale_offset` accepted `fixed_length_utf32`, `null_terminated_bytes`,
`raw_bytes` and `variable_length_bytes`, and the strategies drew them.
The cast_value spec defines the codec only for floating-point and
integral data types.

Assisted-by: ClaudeCode:claude-opus-5-5
`_scope` documented this but raised `ScopeConflictError`, so `declarations`
failed for any definition named as a default, which worked before this
branch. Pipelines and data type names now draw only the definition that
claims a name, and `declarations` reads a draw with its own definition
claiming the name.

Assisted-by: ClaudeCode:claude-opus-5-5
The test compared a draw with the bare name, which depended on the
example Hypothesis returned and said nothing of which definition read
it. Every spelling is now read by the definition it was drawn for.

Assisted-by: ClaudeCode:claude-opus-5-5
@read-the-docs-community

read-the-docs-community Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 zarr-metadata | 🛠️ Build #35635748 | 📁 Comparing d0b4581 against latest (a981abf)

  🔍 Preview build  

1 file changed
± api/testing/index.html

The struct and shard strategies removed the default definition by
identity before drawing what they hold. A custom definition with the
same name stayed in the inner strategies, so it could claim the name
there and be drawn, and the default then refused the result with a
ValueError. Filter by name instead.

Assisted-by: ClaudeCode:claude-opus-5-5
@d-v-b
d-v-b marked this pull request as ready for review November 3, 2026 21:46
d-v-b added 2 commits November 3, 2026 22:59
A run held at most 4 chunks, so the `[size, count]` spelling was never
drawn for what it is for, and a long dimension was covered by a few
small chunks and one huge one. Draw counts sized to the dimension, and
always write a run too long to list as a pair. Reach tests now cover
each spelling of a dimension, not only that a pair is drawn at all.

Assisted-by: ClaudeCode:claude-opus-5-5
…ds evenly

A measured audit found strategies that drew valid metadata from little
of what they could. Hex float fills came from a small-biased integer, so
83% of float64 fills were subnormal and few were normal. Integer float
fills stopped at the limit of the narrowest type. Rectilinear edges
rarely shared a factor, so 70% of a shard's axes held inner chunks of
length 1. A struct field's type was drawn after its name, which made
the first data type about a fifth of all fields.

Draw hex fills from floats, infinities and NaN payloads as well as raw
bits, limit integers by width, draw edges with a common factor, and draw
a field's type first. Divisor search is now bounded, so a very long
shard no longer takes billions of steps. New tests measure shares at the
number of examples a test runs, which plain reach tests do not see.

Assisted-by: ClaudeCode:claude-opus-5-5
@codecov

codecov Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.84%. Comparing base (a981abf) to head (d0b4581).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4597   +/-   ##
=======================================
  Coverage   94.84%   94.84%           
=======================================
  Files          96       96           
  Lines       13997    13997           
=======================================
  Hits        13275    13275           
  Misses        722      722           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

d-v-b added 2 commits November 4, 2026 00:12
… size

Axes can be up to 2**63 - 1 long, but regular and bare rectilinear chunk
lengths reached twice that, which a reader indexing with int64 cannot
hold. Cap them. A rectilinear last edge needs no cap: the runs before it
cover at least one factor, so rounding up cannot pass the axis.

Correct two docstrings, and require a covering run to count more than one
chunk in its reach test, since the leftover edge passed it on its own.

Assisted-by: ClaudeCode:claude-opus-5-5
An offset and a scale are fill values of the chunk's data type, but the
strategy drew only finite floats, and never an integer spelling. It now
draws every spelling a fill value takes, and still never a scale of zero.

Assisted-by: ClaudeCode:claude-opus-5-5
@d-v-b
d-v-b merged commit 630bf36 into zarr-developers:main Nov 4, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs release notes Automatically applied to PRs which haven't added release notes zarr-metadata Specific to the zarr-metadata sub-package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant