Skip to content

Commit

Permalink
test and fix indexing for scalar arrays (zarr-developers#2583)
Browse files Browse the repository at this point in the history
* test and fix indexing for scalar arrays

* fix mypy
  • Loading branch information
brokkoli71 authored Dec 28, 2024
1 parent fb11810 commit 1ac02ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/zarr/api/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ async def array(
z = await create(**kwargs)

# fill with data
await z.setitem(slice(None), data)
await z.setitem(Ellipsis, data)

return z

Expand Down
7 changes: 7 additions & 0 deletions tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,3 +881,10 @@ async def test_nbytes(
assert arr._async_array.nbytes == np.prod(arr.shape) * arr.dtype.itemsize
else:
assert arr.nbytes == np.prod(arr.shape) * arr.dtype.itemsize


async def test_scalar_array() -> None:
arr = zarr.array(1.5)
assert arr[...] == 1.5
assert arr[()] == 1.5
assert arr.shape == ()

0 comments on commit 1ac02ea

Please sign in to comment.