Skip to content

Commit 39b5c07

Browse files
d-v-bbojidar-bg
andcommitted
add shard_grid_shape, chunk_grid_shape
Co-authored-by: Bojidar Marinov <[email protected]>
1 parent cc3698b commit 39b5c07

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

src/zarr/core/array.py

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,31 @@ def cdata_shape(self) -> ChunkCoords:
11921192
Tuple[int]
11931193
The shape of the chunk grid for this array.
11941194
"""
1195-
return tuple(starmap(ceildiv, zip(self.shape, self.chunks, strict=False)))
1195+
return self.chunk_grid_shape
1196+
1197+
@property
1198+
def chunk_grid_shape(self) -> ChunkCoords:
1199+
"""
1200+
The shape of the chunk grid for this array.
1201+
1202+
Returns
1203+
-------
1204+
Tuple[int]
1205+
The shape of the chunk grid for this array.
1206+
"""
1207+
return tuple(starmap(ceildiv, zip(self.shape, self.chunks, strict=True)))
1208+
1209+
@property
1210+
def shard_grid_shape(self) -> ChunkCoords:
1211+
"""
1212+
The shape of the shard grid for this array.
1213+
1214+
Returns
1215+
-------
1216+
Tuple[int]
1217+
The shape of the shard grid for this array.
1218+
"""
1219+
return tuple(starmap(ceildiv, zip(self.shape, self.shards, strict=True)))
11961220

11971221
@property
11981222
def nchunks(self) -> int:
@@ -2198,10 +2222,25 @@ def compressors(self) -> tuple[numcodecs.abc.Codec, ...] | tuple[BytesBytesCodec
21982222

21992223
@property
22002224
def cdata_shape(self) -> ChunkCoords:
2225+
"""
2226+
The shape of the chunk grid for this array. This property exists for backwards compatibility.
2227+
See :func:`chunk_grid_shape` for the preferred method.
2228+
"""
2229+
return self._async_array.chunk_grid_shape
2230+
2231+
@property
2232+
def chunk_grid_shape(self) -> ChunkCoords:
22012233
"""
22022234
The shape of the chunk grid for this array.
22032235
"""
2204-
return tuple(starmap(ceildiv, zip(self.shape, self.chunks, strict=False)))
2236+
return self._async_array.chunk_grid_shape
2237+
2238+
@property
2239+
def shard_grid_shape(self) -> ChunkCoords:
2240+
"""
2241+
The shape of the shard grid for this array.
2242+
"""
2243+
return self._async_array.shard_grid_shape
22052244

22062245
@property
22072246
def nchunks(self) -> int:

0 commit comments

Comments
 (0)