Skip to content

Commit

Permalink
test + dep decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
jhamman committed Dec 7, 2024
1 parent 039c091 commit 6b03c7f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
7 changes: 2 additions & 5 deletions src/zarr/api/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import numpy as np
import numpy.typing as npt
from typing_extensions import deprecated

from zarr.core.array import Array, AsyncArray, get_array_metadata
from zarr.core.buffer import NDArrayLike
Expand Down Expand Up @@ -493,6 +494,7 @@ async def save_group(
await asyncio.gather(*aws)


@deprecated("Use AsyncGroup.tree instead.")
async def tree(grp: AsyncGroup, expand: bool | None = None, level: int | None = None) -> Any:
"""Provide a rich display of the hierarchy.
Expand All @@ -514,11 +516,6 @@ async def tree(grp: AsyncGroup, expand: bool | None = None, level: int | None =
`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)


Expand Down
3 changes: 3 additions & 0 deletions src/zarr/api/synchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from typing import TYPE_CHECKING, Any, Literal

from typing_extensions import deprecated

import zarr.api.asynchronous as async_api
from zarr._compat import _deprecate_positional_args
from zarr.core.array import Array, AsyncArray
Expand Down Expand Up @@ -155,6 +157,7 @@ def save_group(
)


@deprecated("Use Group.tree instead.")
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))

Expand Down
6 changes: 3 additions & 3 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ def test_tree() -> None:
g3.create_group("baz")
g5 = g3.create_group("qux")
g5.create_array("baz", shape=100, chunks=10)
# TODO: complete after tree has been reimplemented
# assert repr(zarr.tree(g1)) == repr(g1.tree())
# assert str(zarr.tree(g1)) == str(g1.tree())
with pytest.warns(DeprecationWarning):
assert repr(zarr.tree(g1)) == repr(g1.tree())
assert str(zarr.tree(g1)) == str(g1.tree())


# @pytest.mark.parametrize("stores_from_path", [False, True])
Expand Down

0 comments on commit 6b03c7f

Please sign in to comment.