@@ -1870,7 +1870,12 @@ def test_unknown_object_codec_default_filters_v2() -> None:
18701870
18711871@pytest .mark .parametrize (
18721872 ("array_shape" , "shard_shape" , "chunk_shape" ),
1873- [((10 ,), None , (1 ,)), ((10 ,), 1 , (1 ,)), ((30 , 10 ), None , (2 , 5 )), ((30 , 10 ), (4 , 10 ), (2 , 5 ))],
1873+ [
1874+ ((10 ,), None , (1 ,)),
1875+ ((10 ,), (1 ,), (1 ,)),
1876+ ((30 , 10 ), None , (2 , 5 )),
1877+ ((30 , 10 ), (4 , 10 ), (2 , 5 )),
1878+ ],
18741879)
18751880def test_chunk_grid_shape (
18761881 array_shape : tuple [int , ...],
@@ -1881,14 +1886,30 @@ def test_chunk_grid_shape(
18811886 """
18821887 Test that the shape of the chunk grid and the shard grid are correctly indicated
18831888 """
1884- arr = zarr .create_array (
1885- {},
1886- dtype = "uint8" ,
1887- shape = array_shape ,
1888- chunks = chunk_shape ,
1889- shards = shard_shape ,
1890- zarr_format = zarr_format ,
1891- )
1889+ if zarr_format == 2 and shard_shape is not None :
1890+ with pytest .raises (
1891+ ValueError ,
1892+ match = "Zarr format 2 arrays can only be created with `shard_shape` set to `None`." ,
1893+ ):
1894+ arr = zarr .create_array (
1895+ {},
1896+ dtype = "uint8" ,
1897+ shape = array_shape ,
1898+ chunks = chunk_shape ,
1899+ shards = shard_shape ,
1900+ zarr_format = zarr_format ,
1901+ )
1902+ pytest .skip ("Zarr format 2 arrays can only be created with `shard_shape` set to `None`." )
1903+ else :
1904+ arr = zarr .create_array (
1905+ {},
1906+ dtype = "uint8" ,
1907+ shape = array_shape ,
1908+ chunks = chunk_shape ,
1909+ shards = shard_shape ,
1910+ zarr_format = zarr_format ,
1911+ )
1912+
18921913 chunk_grid_shape = tuple (ceildiv (a , b ) for a , b in zip (array_shape , chunk_shape , strict = True ))
18931914 if shard_shape is None :
18941915 _shard_shape = chunk_shape
0 commit comments