Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions src/zarr/core/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
from zarr.errors import (
ContainsArrayError,
ContainsGroupError,
GroupNotFoundError,
MetadataValidationError,
ZarrDeprecationWarning,
ZarrUserWarning,
Expand Down Expand Up @@ -673,6 +674,11 @@ def from_dict(
store_path: StorePath,
data: dict[str, Any],
) -> AsyncGroup:
node_type = data.pop("node_type", None)
if node_type == "array":
raise ContainsArrayError(store_path.store, store_path.path)
elif node_type not in ("group", None):
raise GroupNotFoundError(store_path.store, store_path.path)
return cls(
metadata=GroupMetadata.from_dict(data),
store_path=store_path,
Expand Down
6 changes: 6 additions & 0 deletions tests/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -2234,3 +2234,9 @@ def test_get_roots(roots: tuple[str, ...]):
}
data = root_nodes | child_nodes
assert set(_get_roots(data)) == set(roots)


def test_open_array_as_group():
z = zarr.create_array(shape=(40, 50), chunks=(10, 10), dtype="f8", store={})
with pytest.raises(ContainsArrayError):
zarr.open_group(z.store)
Loading