Repository navigation
Commit 630bf36
authored
feat(zarr-metadata): draw nested fields and codec pipelines (#4597)
* feat(zarr-metadata): draw nested fields and codec pipelines
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
* fix(zarr-metadata): reject non-numeric data types in arithmetic codecs
`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
* fix(zarr-metadata): let the later of two same-named strategies win
`_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
* test(zarr-metadata): check a same-named definition reads its own draws
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
* chore(zarr-metadata): number the nested strategies changelog fragments after #4597
Assisted-by: ClaudeCode:claude-opus-5-5
* fix(zarr-metadata): keep same-named definitions out of nested draws
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
* fix(zarr-metadata): draw long runs in rectilinear dimensions
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
* fix(zarr-metadata): sample float fills, shard factors and struct fields 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
* fix(zarr-metadata): keep regular chunk lengths within a signed 64-bit 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
* fix(zarr-metadata): draw non-finite and hex scale_offset values
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-51 parent a981abf commit 630bf36
14 files changed
Lines changed: 1831 additions & 315 deletions
File tree
- packages/zarr-metadata
- changes
- src/zarr_metadata
- testing
- v3/codec
- tests
- testing
- v3
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
19 | 23 | | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
23 | | - | |
| 27 | + | |
24 | 28 | | |
25 | 29 | | |
26 | 30 | | |
27 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
28 | 35 | | |
29 | 36 | | |
30 | 37 | | |
31 | 38 | | |
32 | | - | |
33 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
34 | 50 | | |
35 | 51 | | |
36 | 52 | | |
37 | | - | |
| 53 | + | |
38 | 54 | | |
39 | 55 | | |
40 | | - | |
| 56 | + | |
41 | 57 | | |
42 | 58 | | |
43 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
44 | 62 | | |
45 | 63 | | |
46 | 64 | | |
47 | 65 | | |
48 | 66 | | |
49 | | - | |
| 67 | + | |
| 68 | + | |
50 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
51 | 74 | | |
52 | | - | |
53 | | - | |
54 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
55 | 79 | | |
56 | 80 | | |
57 | 81 | | |
58 | 82 | | |
59 | 83 | | |
60 | | - | |
| 84 | + | |
61 | 85 | | |
62 | 86 | | |
63 | 87 | | |
64 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
65 | 93 | | |
66 | 94 | | |
67 | 95 | | |
68 | 96 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
74 | 102 | | |
75 | | - | |
| 103 | + | |
| 104 | + | |
76 | 105 | | |
77 | 106 | | |
78 | | - | |
79 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
80 | 110 | | |
81 | 111 | | |
82 | 112 | | |
83 | 113 | | |
84 | 114 | | |
85 | | - | |
| 115 | + | |
86 | 116 | | |
87 | 117 | | |
88 | 118 | | |
89 | 119 | | |
90 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
91 | 123 | | |
92 | 124 | | |
93 | 125 | | |
94 | 126 | | |
95 | 127 | | |
96 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
97 | 133 | | |
98 | 134 | | |
99 | 135 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
24 | 34 | | |
25 | 35 | | |
26 | 36 | | |
27 | 37 | | |
28 | | - | |
29 | | - | |
30 | | - | |
| 38 | + | |
31 | 39 | | |
32 | 40 | | |
33 | | - | |
34 | | - | |
35 | | - | |
| 41 | + | |
36 | 42 | | |
37 | 43 | | |
38 | 44 | | |
| |||
0 commit comments