|
35 | 35 | from zarr.core.buffer import NDArrayLike, default_buffer_prototype |
36 | 36 | from zarr.core.dtype import Int32 |
37 | 37 | from zarr.core.indexing import lexicographic_order_coords |
| 38 | +from zarr.errors import ZarrDeprecationWarning |
38 | 39 | from zarr.core.metadata.v3 import ArrayV3Metadata |
39 | 40 | from zarr.storage import MemoryStore, StorePath, ZipStore |
40 | 41 |
|
@@ -1492,15 +1493,25 @@ def test_nested_sharding_rejects_indivisible_inner_chunk_shape( |
1492 | 1493 | assert store._store_dict == {} |
1493 | 1494 |
|
1494 | 1495 |
|
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]) |
1496 | 1497 | 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 |
1498 | 1499 | constructed, with a `ValueError` naming the dimension, so no array metadata, nested |
1499 | 1500 | codec or stored document can hold one.""" |
1500 | 1501 | with pytest.raises(ValueError, match=r"Dimension \d: chunk edge length must be >= 1, got"): |
1501 | 1502 | ShardingCodec(chunk_shape=chunk_shape) |
1502 | 1503 |
|
1503 | 1504 |
|
| 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 | + |
1504 | 1515 | @pytest.mark.filterwarnings( |
1505 | 1516 | "ignore:Combining a `sharding_indexed` codec:zarr.errors.ZarrUserWarning" |
1506 | 1517 | ) |
|
0 commit comments