Skip to content

feat(zarr-metadata): draw whole v3 documents - #439

Draft
d-v-b wants to merge 3 commits into
claude/zarr-metadata-nested-strategiesfrom
claude/zarr-metadata-document-strategies
Draft

d-v-b wants to merge 3 commits into
claude/zarr-metadata-nested-strategiesfrom
claude/zarr-metadata-document-strategies

Conversation

@d-v-b

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

Copy link
Copy Markdown
Owner

🤖 AI text below 🤖

Added array_documents, group_documents and consolidated_group_documents to zarr_metadata.testing.strategies, which draw whole Zarr v3 documents. An array's members are drawn to fit each other: the chunk grid for the shape, the fill value for the data type, and the codecs for the grid's chunks of that data type. pipelines now takes spellings, as declarations does.

How the document strategies work

  • A drawn document is read by the package's reader before it is returned, and one its definitions refuse raises a ValueError. Strategies with nothing to draw a required member from raise a LookupError that names what is missing.
  • A data type that no array -> bytes codec in the strategies takes is not drawn. If that is every data type they hold, Hypothesis reports the strategy as unsatisfiable.
  • spellings="canonical" applies to declarations. A fill value is drawn in every spelling its data type's spec gives it, either way.
  • A member the spec does not define is always an object that says must_understand is false, so a reader may ignore it.
  • A consolidated listing is flat, and each node's parent is a group it also lists. A listed group has no listing of its own, or the empty one the reference implementation writes.
  • A shape has each number of axes up to 8 about as often as any other, and axes that are zero, short, or up to 2**63 - 1.
  • A document's data type is drawn first. Drawn after the shape, the first data type in the list made up about a fifth of all documents.

Tests

  • Each document is read in ZARR_PYTHON_CONTEXT. Arrays and groups are read as drawn and after a JSON round trip, and consolidated listings as drawn.
  • Reach tests cover every definition, each optional member present and absent, no axes, a zero-length axis, a shard over a rectilinear grid, a listed node below a listed group, and a listed group with and without an empty listing.
  • Share tests bound how often a few hundred examples hold no axes, more than five axes, a zero-length axis, an axis past 32 bits, and the first data type. The bounds are wide, because a share can move a few points between processes.
  • The agent planted bugs in the new module and in the later sampling fixes, and the suite catches each of them. Three name-filter bugs survived at first, so the strategies now draw reserved names on purpose and filter them out.
  • just check is green on Python 3.11 and 3.14 (3587 passed, 3 skipped; 3590 passed).

Left open

  • storage_transformers is drawn only as empty, because no strategy defines one.
  • A listed group never holds a non-empty listing of its own.
  • A definition that claims an extra field has no way to be drawn. A custom strategy cannot add one yet.
  • v2 documents are planned as a separate PR.
Stack

PR 3 of the strategies stack, based on claude/zarr-metadata-nested-strategies (#416, upstream zarr-developers#4597). Merge that first, then retarget this to main.

🤖 Generated with Claude Code

d-v-b added a commit that referenced this pull request Nov 3, 2026
…nt after #439

Assisted-by: ClaudeCode:claude-opus-5-5
d-v-b added a commit that referenced this pull request Nov 3, 2026
…nt after #439

Assisted-by: ClaudeCode:claude-opus-5-5
@d-v-b
d-v-b force-pushed the claude/zarr-metadata-document-strategies branch from f15c9d3 to c211013 Compare November 3, 2026 21:48
d-v-b added a commit that referenced this pull request Nov 3, 2026
…nt after #439

Assisted-by: ClaudeCode:claude-opus-5-5
@d-v-b
d-v-b force-pushed the claude/zarr-metadata-document-strategies branch from c211013 to 1b955ce Compare November 3, 2026 22:46
d-v-b added a commit that referenced this pull request Nov 3, 2026
…nt after #439

Assisted-by: ClaudeCode:claude-opus-5-5
@d-v-b
d-v-b force-pushed the claude/zarr-metadata-document-strategies branch from 1b955ce to e9bc2fb Compare November 3, 2026 23:21
d-v-b added 3 commits November 4, 2026 07:25
Add `array_documents`, `group_documents` and
`consolidated_group_documents`. An array's members are drawn to fit each
other: the chunk grid for the shape, the fill value for the data type,
and the codecs for the grid's chunks of that data type. A consolidated
listing holds each node's parent, as a group, before the node.

`pipelines` takes `spellings`, as `declarations` does. A drawn document
its definitions refuse raises a ValueError, and strategies with nothing
to draw some member from raise a LookupError. `Spellings` and
`CHARACTERS` move to `_strategy` so the new module can share them.

Assisted-by: ClaudeCode:claude-opus-5-5
…nt after #439

Assisted-by: ClaudeCode:claude-opus-5-5
…venly

Shapes capped axes at 2**16 and rank at 5, with a quarter of documents
rank 0 and few holding a zero-length axis. Draw each rank about as often,
up to 8, and axes that are zero, short, or past 32 bits. Draw a document's
data type first: drawn after the shape, the first in the list was a fifth
of all documents. A listed group now sometimes holds the empty listing
the reference implementation writes, a fresh one for each group. New
tests bound these shares.

Assisted-by: ClaudeCode:claude-opus-5-5
@d-v-b
d-v-b force-pushed the claude/zarr-metadata-document-strategies branch from e9bc2fb to e8ef016 Compare November 4, 2026 07:51

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant