@@ -1863,6 +1863,37 @@ def test_unknown_object_codec_default_filters_v2() -> None:
18631863 default_filters_v2 (dtype )
18641864
18651865
1866+ @pytest .mark .parametrize (
1867+ ("array_shape" , "shard_shape" , "chunk_shape" ), [((10 ,), None , (1 ,)), ((30 , 10 ), None , (2 , 5 ))]
1868+ )
1869+ def test_chunk_grid_shape (
1870+ array_shape : tuple [int , ...],
1871+ shard_shape : tuple [int , ...] | None ,
1872+ chunk_shape : tuple [int , ...],
1873+ zarr_format : ZarrFormat ,
1874+ ) -> None :
1875+ """
1876+ Test that the shape of the chunk grid and the shard grid are correctly indicated
1877+ """
1878+ arr = zarr .create_array (
1879+ {},
1880+ dtype = "uint8" ,
1881+ shape = array_shape ,
1882+ chunks = chunk_shape ,
1883+ shards = shard_shape ,
1884+ zarr_format = zarr_format ,
1885+ )
1886+ chunk_grid_shape = tuple (ceildiv (a , b ) for a , b in zip (array_shape , chunk_shape , strict = True ))
1887+ if shard_shape is None :
1888+ _shard_shape = chunk_shape
1889+ else :
1890+ _shard_shape = shard_shape
1891+ shard_grid_shape = tuple (ceildiv (a , b ) for a , b in zip (array_shape , _shard_shape , strict = True ))
1892+ assert arr .chunk_grid_shape == chunk_grid_shape
1893+ assert arr .cdata_shape == chunk_grid_shape
1894+ assert arr .shard_grid_shape == shard_grid_shape
1895+
1896+
18661897@pytest .mark .parametrize (
18671898 ("array_shape" , "shard_shape" , "chunk_shape" ), [((10 ,), None , (1 ,)), ((30 , 10 ), None , (2 , 5 ))]
18681899)
0 commit comments