From f063515ab036b755cc92964fe2479fac571f9090 Mon Sep 17 00:00:00 2001 From: brokkoli71 Date: Tue, 22 Oct 2024 11:57:04 +0200 Subject: [PATCH] improve test_sharding_with_chunks_per_shard --- tests/test_codecs/test_sharding.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/test_codecs/test_sharding.py b/tests/test_codecs/test_sharding.py index f4710dd55..f7cb287b8 100644 --- a/tests/test_codecs/test_sharding.py +++ b/tests/test_codecs/test_sharding.py @@ -396,14 +396,16 @@ async def test_sharding_with_empty_inner_chunk( @pytest.mark.parametrize("store", ["local", "memory"], indirect=["store"]) @pytest.mark.parametrize( - "index_location", [ShardingCodecIndexLocation.start, ShardingCodecIndexLocation.end] + "index_location", [ShardingCodecIndexLocation.start, ShardingCodecIndexLocation.end], ) -async def test_sharding2(store: Store, index_location: ShardingCodecIndexLocation) -> None: - shape = (10, 2) +@pytest.mark.parametrize("chunks_per_shard", [(5,2), (2,5), (5,5)]) +async def test_sharding_with_chunks_per_shard(store: Store, index_location: ShardingCodecIndexLocation, chunks_per_shard: tuple) -> None: + chunk_shape = (2,1) + shape = [x*y for x,y in zip(chunks_per_shard, chunk_shape, strict=False)] data = np.ones(np.prod(shape), dtype="int32").reshape(shape) fill_value = 42 - path = f"test_sharding_2{index_location}" + path = f"test_sharding_with_chunks_per_shard_{index_location}" spath = StorePath(store, path) a = Array.create( spath, @@ -411,7 +413,7 @@ async def test_sharding2(store: Store, index_location: ShardingCodecIndexLocatio chunk_shape=shape, dtype="int32", fill_value=fill_value, - codecs=[ShardingCodec(chunk_shape=(2, 1), index_location=index_location)], + codecs=[ShardingCodec(chunk_shape=chunk_shape, index_location=index_location)], ) a[...] = data data_read = a[...]