Skip to content

Commit 90f6ce9

Browse files
authored
Merge branch 'main' into fix/pcodec-typo
2 parents 8702046 + 0278494 commit 90f6ce9

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/zarr/codecs/sharding.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,8 @@ def validate(
431431
)
432432
):
433433
raise ValueError(
434-
"The array's `chunk_shape` needs to be divisible by the shard's inner `chunk_shape`."
434+
f"The array's `chunk_shape` (got {chunk_grid.chunk_shape}) "
435+
f"needs to be divisible by the shard's inner `chunk_shape` (got {self.chunk_shape})."
435436
)
436437

437438
async def _decode_single(

tests/test_codecs/test_sharding.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pickle
2+
import re
23
from typing import Any
34

45
import numpy as np
@@ -486,3 +487,20 @@ def test_invalid_metadata(store: Store) -> None:
486487
dtype=np.dtype("uint8"),
487488
fill_value=0,
488489
)
490+
491+
492+
def test_invalid_shard_shape() -> None:
493+
with pytest.raises(
494+
ValueError,
495+
match=re.escape(
496+
"The array's `chunk_shape` (got (16, 16)) needs to be divisible by the shard's inner `chunk_shape` (got (9,))."
497+
),
498+
):
499+
zarr.create_array(
500+
{},
501+
shape=(16, 16),
502+
shards=(16, 16),
503+
chunks=(9,),
504+
dtype=np.dtype("uint8"),
505+
fill_value=0,
506+
)

0 commit comments

Comments
 (0)