Repository navigation
Commit d21a5b4
authored
fix(zarr-metadata): attributes may hold NaN and the infinities (#4420)
zarr-python writes attributes with the defaults of Python's `json`
module, so an xarray `_FillValue` of NaN is stored as a bare `NaN`, and
the model refused to read such a store. Attributes are user data, which
the spec asks only to be JSON values and never interprets, so a
non-finite number in them is now read, validated and written back as
Python's `json` writes it. Anywhere the spec interprets a value one is
still refused, and the store reader now says where instead of failing to
decode the document.
`refine_json` walks a value once, normalizing and judging it, and
`refine_user_data` is the same walk where a non-finite number is the
float it is. Only the validators say where user data is: they walk a
node's attributes with `refine_user_data`, the store reader decodes and
leaves the judging to them, and `to_key_value` validates what it writes
with the `parse_*` its reader uses, so it no longer writes a document
the reader refuses.
Assisted-by: ClaudeCode:claude-opus-5-51 parent 4aeac75 commit d21a5b4
9 files changed
Lines changed: 636 additions & 69 deletions
File tree
- packages/zarr-metadata
- changes
- src/zarr_metadata
- model
- tests/model
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
331 | | - | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
332 | 335 | | |
333 | 336 | | |
334 | 337 | | |
| |||
493 | 496 | | |
494 | 497 | | |
495 | 498 | | |
496 | | - | |
497 | | - | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
498 | 504 | | |
499 | 505 | | |
500 | 506 | | |
501 | | - | |
502 | | - | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
503 | 511 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
28 | | - | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
182 | 183 | | |
183 | 184 | | |
184 | 185 | | |
185 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
186 | 190 | | |
187 | 191 | | |
188 | 192 | | |
| |||
339 | 343 | | |
340 | 344 | | |
341 | 345 | | |
342 | | - | |
343 | | - | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
344 | 351 | | |
345 | 352 | | |
346 | 353 | | |
347 | | - | |
348 | | - | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
349 | 358 | | |
350 | 359 | | |
351 | 360 | | |
| |||
399 | 408 | | |
400 | 409 | | |
401 | 410 | | |
| 411 | + | |
402 | 412 | | |
403 | 413 | | |
404 | 414 | | |
| |||
410 | 420 | | |
411 | 421 | | |
412 | 422 | | |
| 423 | + | |
| 424 | + | |
413 | 425 | | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
419 | 430 | | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
420 | 434 | | |
421 | 435 | | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
| 436 | + | |
427 | 437 | | |
428 | 438 | | |
429 | 439 | | |
| |||
432 | 442 | | |
433 | 443 | | |
434 | 444 | | |
435 | | - | |
436 | | - | |
437 | | - | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
0 commit comments