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
29 changes: 27 additions & 2 deletions src/zarr/api/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,33 @@ async def save_group(
await asyncio.gather(*aws)


async def tree(*args: Any, **kwargs: Any) -> None:
raise NotImplementedError
async def tree(grp: AsyncGroup, expand: bool | None = None, level: int | None = None) -> Any:
"""Provide a rich display of the hierarchy.

Parameters
----------
grp : Group
Zarr or h5py group.
expand : bool, optional
Only relevant for HTML representation. If True, tree will be fully expanded.
level : int, optional
Maximum depth to descend into hierarchy.

Returns
-------
TreeRepr
A pretty-printable object displaying the hierarchy.

.. deprecated:: 3.0.0
`zarr.tree()` is deprecated and will be removed in a future release.
Use `group.tree()` instead.
"""
warnings.warn(
"zarr.tree() is deprecated and will be removed in a future release. Use group.tree() instead.",
DeprecationWarning,
stacklevel=2,
)
return await grp.tree(expand=expand, level=level)


async def array(
Expand Down
4 changes: 2 additions & 2 deletions src/zarr/api/synchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ def save_group(
)


def tree(*args: Any, **kwargs: Any) -> None:
return sync(async_api.tree(*args, **kwargs))
def tree(grp: Group, expand: bool | None = None, level: int | None = None) -> Any:
return sync(async_api.tree(grp._async_group, expand=expand, level=level))


# TODO: add type annotations for kwargs
Expand Down
2 changes: 1 addition & 1 deletion src/zarr/core/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -1449,7 +1449,7 @@ async def tree(self, expand: bool | None = None, level: int | None = None) -> An
from zarr.core._tree import group_tree_async

if expand is not None:
raise NotImplementedError("'expanded' is not yet implemented.")
raise NotImplementedError("'expand' is not yet implemented.")
return await group_tree_async(self, max_depth=level)

async def empty(
Expand Down
Loading