Skip to content

Commit

Permalink
Merge branch 'v3' into feature/top-level-api
Browse files Browse the repository at this point in the history
  • Loading branch information
jhamman committed Jun 3, 2024
2 parents 4fd06cd + da9885c commit 0f071b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/zarr/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,15 @@ def ndim(self) -> int:
def shape(self) -> ChunkCoords:
return self.metadata.shape

@property
def chunks(self) -> ChunkCoords:
if isinstance(self.metadata.chunk_grid, RegularChunkGrid):
return self.metadata.chunk_grid.chunk_shape
else:
raise ValueError(
f"chunk attribute is only available for RegularChunkGrid, this array has a {self.metadata.chunk_grid}"
)

@property
def size(self) -> int:
return np.prod(self.metadata.shape).item()
Expand Down Expand Up @@ -645,6 +654,10 @@ def ndim(self) -> int:
def shape(self) -> ChunkCoords:
return self._async_array.shape

@property
def chunks(self) -> ChunkCoords:
return self._async_array.chunks

@property
def size(self) -> int:
return self._async_array.size
Expand Down
2 changes: 1 addition & 1 deletion tests/v3/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_group(store: MemoryStore | LocalStore) -> None:
assert arr.dtype == data.dtype

# TODO: update this once the array api settles down
# assert arr.chunk_shape == (2, 2)
assert arr.chunks == (2, 2)

bar2 = foo["bar"]
assert dict(bar2.attrs) == {"baz": "qux"}
Expand Down

0 comments on commit 0f071b0

Please sign in to comment.