Repository navigation
Commit 0b053b2
authored
fix(dtype): write the generic time unit in brackets in Zarr format 2 metadata (zarr-developers#4581)
* fix(dtype): write the generic time unit in brackets in Zarr format 2 metadata
The v2 spec requires the unit of a datetime64 or timedelta64 dtype in
brackets, but a generic-unit time dtype serialized as NumPy's unitless
typestr (<M8), which the spec forbids. The generic unit is now written
explicitly — <M8[generic], or <M8[2generic] with a scale, as scaled
generic units already were — which NumPy parses back to the same dtype.
The unitless spellings stay readable as the generic unit.
Fixes zarr-developers#4580
Assisted-by: ClaudeCode:claude-fable-5
* docs: changelog fragment for #421
Assisted-by: ClaudeCode:claude-fable-5
* refactor(dtype): share the v2 time typestr spelling between the two time types
The generic-unit bracketing moves to TimeDTypeBase._v2_name, which both
to_json implementations call, instead of being duplicated in each.
Assisted-by: ClaudeCode:claude-fable-5
* test(dtype): check v2 JSON alias spellings through the shared wrapper tests
The one-off unitless-time test becomes json_alias_v2_params on the
shared dtype test base: (alias, canonical) pairs asserting that reading
either spelling gives the same dtype and writing gives the canonical
one. The time types list the unitless generic spellings and NumPy's
microsecond alias; other types can list their aliases the same way.
Assisted-by: ClaudeCode:claude-fable-51 parent bf0d231 commit 0b053b2
4 files changed
Lines changed: 60 additions & 13 deletions
File tree
- changes
- src/zarr/core/dtype/npy
- tests/test_dtype
- test_npy
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
242 | 252 | | |
243 | 253 | | |
244 | 254 | | |
| |||
497 | 507 | | |
498 | 508 | | |
499 | 509 | | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
| 510 | + | |
505 | 511 | | |
506 | 512 | | |
507 | 513 | | |
| |||
785 | 791 | | |
786 | 792 | | |
787 | 793 | | |
788 | | - | |
789 | | - | |
790 | | - | |
791 | | - | |
792 | | - | |
| 794 | + | |
793 | 795 | | |
794 | 796 | | |
795 | 797 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
| 37 | + | |
37 | 38 | | |
38 | | - | |
39 | | - | |
40 | 39 | | |
41 | 40 | | |
42 | 41 | | |
| |||
81 | 80 | | |
82 | 81 | | |
83 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
84 | 100 | | |
85 | 101 | | |
86 | 102 | | |
| |||
125 | 141 | | |
126 | 142 | | |
127 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
128 | 159 | | |
129 | 160 | | |
130 | 161 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
93 | 98 | | |
94 | 99 | | |
95 | 100 | | |
| |||
127 | 132 | | |
128 | 133 | | |
129 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
130 | 143 | | |
131 | 144 | | |
132 | 145 | | |
| |||
0 commit comments