Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/3469.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed `save_array`, `Group.__setitem__`, and `load` for 0-dimensional arrays.
4 changes: 2 additions & 2 deletions src/zarr/api/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ async def load(

obj = await open(store=store, path=path, zarr_format=zarr_format)
if isinstance(obj, AsyncArray):
return await obj.getitem(slice(None))
return await obj.getitem(Ellipsis)
else:
raise NotImplementedError("loading groups not yet supported")

Expand Down Expand Up @@ -482,7 +482,7 @@ async def save_array(
overwrite=overwrite,
**kwargs,
)
await new.setitem(slice(None), arr)
await new.setitem(Ellipsis, arr)


async def save_group(
Expand Down
16 changes: 16 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,22 @@ def test_save(store: Store, n_args: int, n_kwargs: int, path: None | str) -> Non
assert group.nmembers() == n_args + n_kwargs


@pytest.mark.parametrize(
"data",
[
np.array(42, dtype=np.int64),
np.array("teststr", dtype=np.bytes_),
],
)
@pytest.mark.filterwarnings("ignore::zarr.errors.UnstableSpecificationWarning")
def test_group_setitem_loads_scalar_arrays(sync_store: Store, data: np.ndarray) -> None:
root = zarr.open_group(store=sync_store)
root["test"] = data

assert_array_equal(root["test"][...], data)
assert_array_equal(zarr.load(store=sync_store, path="test"), data)


def test_save_errors() -> None:
with pytest.raises(ValueError, match="at least one array must be provided"):
# no arrays provided
Expand Down
Loading