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/3428.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure syntax like ``root['/subgroup']`` works equivalently to ``root['subgroup']`` when using consolidated metadata.
2 changes: 1 addition & 1 deletion src/zarr/core/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ def _getitem_consolidated(
assert self.metadata.consolidated_metadata is not None

# we support nested getitems like group/subgroup/array
indexers = key.split("/")
indexers = normalize_path(key).split("/")
indexers.reverse()
metadata: ArrayV2Metadata | ArrayV3Metadata | GroupMetadata = self.metadata

Expand Down
15 changes: 15 additions & 0 deletions tests/test_metadata/test_consolidated.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,21 @@ async def test_use_consolidated_for_children_members(
expected = ["b", "b/c"]
assert result == expected

async def test_absolute_path_for_subgroup(self, memory_store: zarr.storage.MemoryStore) -> None:
root = await zarr.api.asynchronous.create_group(store=memory_store)
await root.create_group("a/b")
with pytest.warns(
ZarrUserWarning,
match="Consolidated metadata is currently not part in the Zarr format 3 specification.",
):
await zarr.api.asynchronous.consolidate_metadata(memory_store)

group = await zarr.api.asynchronous.open_group(store=memory_store)
subgroup = await group.getitem("/a")
assert isinstance(subgroup, AsyncGroup)
members = [x async for x in subgroup.keys()] # noqa: SIM118
assert members == ["b"]


@pytest.mark.parametrize("fill_value", [np.nan, np.inf, -np.inf])
async def test_consolidated_metadata_encodes_special_chars(
Expand Down
Loading