Repository navigation
Commit 069fd20
authored
fix(sharding): validate nested sharding codecs and reject an inner chunk size of 0 (#4480)
* fix(sharding): validate nested sharding codecs and reject an inner chunk size of 0
`ShardingCodec.validate` checked its own inner chunk shape against the chunk
grid but never validated the codecs that encode each inner chunk. A sharding
codec nested in another one could therefore declare an inner chunk shape that
does not divide the chunk it splits: the array was created and opened without
error, and then read back wrong data or its fill value.
`validate` now validates the inner codecs as array metadata validates its
codecs: each against the chunk the codecs before it leave it (so permuted
after a transpose), as a regular grid of one inner chunk.
`ShardingCodec` also rejects an inner chunk size of 0 (or `False`) when it is
constructed or unpickled, as tensorstore and zarrs do when they parse the
codec configuration. It used to accept one, which raised a
`ZeroDivisionError` when an array used the codec or, where the codec was
nested, on the first write.
Assisted-by: ClaudeCode:claude-fable-5.1
* docs(changes): name the changelog fragment after the pull request
Assisted-by: ClaudeCode:claude-fable-5.11 parent a53d51f commit 069fd20
4 files changed
Lines changed: 133 additions & 11 deletions
File tree
- changes
- src/zarr/codecs
- tests
- test_codecs
- test_metadata
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
437 | 438 | | |
438 | 439 | | |
439 | 440 | | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
440 | 447 | | |
441 | 448 | | |
442 | 449 | | |
| |||
468 | 475 | | |
469 | 476 | | |
470 | 477 | | |
471 | | - | |
| 478 | + | |
472 | 479 | | |
473 | 480 | | |
474 | 481 | | |
| |||
507 | 514 | | |
508 | 515 | | |
509 | 516 | | |
510 | | - | |
| 517 | + | |
511 | 518 | | |
512 | 519 | | |
513 | 520 | | |
| |||
635 | 642 | | |
636 | 643 | | |
637 | 644 | | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
638 | 667 | | |
639 | 668 | | |
640 | 669 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
768 | 769 | | |
769 | 770 | | |
770 | 771 | | |
771 | | - | |
772 | 772 | | |
773 | | - | |
| 773 | + | |
774 | 774 | | |
775 | 775 | | |
776 | 776 | | |
777 | 777 | | |
778 | | - | |
779 | | - | |
| 778 | + | |
780 | 779 | | |
781 | 780 | | |
782 | 781 | | |
| |||
1436 | 1435 | | |
1437 | 1436 | | |
1438 | 1437 | | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
519 | 519 | | |
520 | 520 | | |
521 | 521 | | |
522 | | - | |
523 | | - | |
524 | 522 | | |
525 | 523 | | |
526 | 524 | | |
527 | 525 | | |
528 | 526 | | |
529 | 527 | | |
530 | 528 | | |
531 | | - | |
532 | | - | |
533 | | - | |
| 529 | + | |
| 530 | + | |
534 | 531 | | |
535 | 532 | | |
536 | 533 | | |
537 | 534 | | |
538 | 535 | | |
539 | 536 | | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
540 | 546 | | |
541 | 547 | | |
542 | 548 | | |
| |||
0 commit comments