@@ -394,35 +394,21 @@ def validate(
394394 "The shard's `chunk_shape` and array's `shape` need to have the same number of dimensions."
395395 )
396396 if isinstance (chunk_grid , RegularChunkGrid ):
397- if not all (
398- s % c == 0
399- for s , c in zip (
400- chunk_grid .chunk_shape ,
401- self .chunk_shape ,
402- strict = False ,
403- )
404- ):
405- raise ValueError (
406- f"The array's `chunk_shape` (got { chunk_grid .chunk_shape } ) "
407- f"needs to be divisible by the shard's inner `chunk_shape` (got { self .chunk_shape } )."
408- )
397+ edges_per_dim : tuple [tuple [int , ...], ...] = tuple ((s ,) for s in chunk_grid .chunk_shape )
409398 elif isinstance (chunk_grid , RectilinearChunkGrid ):
410- # For rectilinear grids, every unique edge length per dimension
411- # must be divisible by the corresponding inner chunk size.
412- for i , (edges , inner ) in enumerate (
413- zip (chunk_grid .chunk_shapes , self .chunk_shape , strict = False )
414- ):
415- for edge in set (edges ):
416- if edge % inner != 0 :
417- raise ValueError (
418- f"Chunk edge length { edge } in dimension { i } is not "
419- f"divisible by the shard's inner chunk size { inner } ."
420- )
399+ edges_per_dim = chunk_grid .chunk_shapes
421400 else :
422401 raise TypeError (
423402 f"Sharding is only compatible with regular and rectilinear chunk grids, "
424403 f"got { type (chunk_grid )} "
425404 )
405+ for i , (edges , inner ) in enumerate (zip (edges_per_dim , self .chunk_shape , strict = False )):
406+ for edge in set (edges ):
407+ if edge % inner != 0 :
408+ raise ValueError (
409+ f"Chunk edge length { edge } in dimension { i } is not "
410+ f"divisible by the shard's inner chunk size { inner } ."
411+ )
426412
427413 async def _decode_single (
428414 self ,
0 commit comments