Skip to content

Commit 4906534

Browse files
committed
test: expect deprecation warning for False in sharding chunk shape
1 parent 5a4f169 commit 4906534

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎tests/test_codecs/test_sharding.py‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from zarr.core.buffer import NDArrayLike, default_buffer_prototype
3636
from zarr.core.dtype import Int32
3737
from zarr.core.indexing import lexicographic_order_coords
38+
from zarr.errors import ZarrDeprecationWarning
3839
from zarr.core.metadata.v3 import ArrayV3Metadata
3940
from zarr.storage import MemoryStore, StorePath, ZipStore
4041

@@ -1492,15 +1493,25 @@ def test_nested_sharding_rejects_indivisible_inner_chunk_shape(
14921493
assert store._store_dict == {}
14931494

14941495

1495-
@pytest.mark.parametrize("chunk_shape", [(0, 5), (5, 0), (False, 5), [0], 0])
1496+
@pytest.mark.parametrize("chunk_shape", [(0, 5), (5, 0), [0], 0])
14961497
def test_sharding_codec_rejects_inner_chunk_size_zero(chunk_shape: Any) -> None:
1497-
"""`ShardingCodec` rejects an inner chunk size of 0 (or `False`) when it is
1498+
"""`ShardingCodec` rejects an inner chunk size of 0 when it is
14981499
constructed, with a `ValueError` naming the dimension, so no array metadata, nested
14991500
codec or stored document can hold one."""
15001501
with pytest.raises(ValueError, match=r"Dimension \d: chunk edge length must be >= 1, got"):
15011502
ShardingCodec(chunk_shape=chunk_shape)
15021503

15031504

1505+
def test_sharding_codec_rejects_inner_chunk_size_false() -> None:
1506+
"""`False` in an inner chunk shape warns (booleans in shape-like fields are
1507+
deprecated) and is still rejected as a zero edge length."""
1508+
with pytest.warns(ZarrDeprecationWarning, match="Boolean values in shape-like"):
1509+
with pytest.raises(
1510+
ValueError, match=r"Dimension \d: chunk edge length must be >= 1, got"
1511+
):
1512+
ShardingCodec(chunk_shape=(False, 5))
1513+
1514+
15041515
@pytest.mark.filterwarnings(
15051516
"ignore:Combining a `sharding_indexed` codec:zarr.errors.ZarrUserWarning"
15061517
)

0 commit comments

Comments
 (0)