Skip to content
Open
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
4 changes: 4 additions & 0 deletions changes/4521.removal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
The following have been removed, having been deprecated since Zarr-Python 3.0.0:

- `zarr.tree`, `zarr.api.synchronous.tree` and `zarr.api.asynchronous.tree`. Use `Group.tree` / `AsyncGroup.tree` instead.
- The `Array.compressor` and `AsyncArray.compressor` properties. Use `Array.compressors` instead (for Zarr format 2 arrays, `compressors[0]` is the old `compressor`, and an empty tuple means no compressor).
2 changes: 0 additions & 2 deletions src/zarr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
save,
save_array,
save_group,
tree,
zeros,
zeros_like,
)
Expand Down Expand Up @@ -179,7 +178,6 @@ def set_format(log_format: str) -> None:
"save",
"save_array",
"save_group",
"tree",
"zeros",
"zeros_like",
]
28 changes: 0 additions & 28 deletions src/zarr/api/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

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

from zarr.abc.store import Store
from zarr.core.array import (
Expand Down Expand Up @@ -43,7 +42,6 @@
ArrayNotFoundError,
GroupNotFoundError,
NodeTypeValidationError,
ZarrDeprecationWarning,
ZarrRuntimeWarning,
ZarrUserWarning,
)
Expand Down Expand Up @@ -91,7 +89,6 @@
"save",
"save_array",
"save_group",
"tree",
"zeros",
"zeros_like",
]
Expand Down Expand Up @@ -615,31 +612,6 @@ async def save_group(
await asyncio.gather(*aws)


@deprecated("Use AsyncGroup.tree instead.", category=ZarrDeprecationWarning)
async def tree(grp: AsyncGroup, expand: bool | None = None, level: int | None = None) -> Any:
"""Provide a rich display of the hierarchy.

!!! warning "Deprecated"
`zarr.tree()` is deprecated since v3.0.0 and will be removed in a future release.
Use `group.tree()` instead.

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.
"""
return await grp.tree(expand=expand, level=level)


async def array(data: npt.ArrayLike | AnyArray, **kwargs: Any) -> AnyAsyncArray:
"""Create an array filled with `data`.

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

from typing import TYPE_CHECKING, Any, Literal

from typing_extensions import deprecated

import zarr.api.asynchronous as async_api
import zarr.core.array
from zarr.core.array import DEFAULT_FILL_VALUE, Array, AsyncArray, CompressorLike
from zarr.core.group import Group
from zarr.core.sync import sync
from zarr.core.sync_group import create_hierarchy
from zarr.errors import ZarrDeprecationWarning

if TYPE_CHECKING:
from collections.abc import Iterable
Expand Down Expand Up @@ -69,7 +66,6 @@
"save",
"save_array",
"save_group",
"tree",
"zeros",
"zeros_like",
]
Expand Down Expand Up @@ -382,31 +378,6 @@ def save_group(
)


@deprecated("Use Group.tree instead.", category=ZarrDeprecationWarning)
def tree(grp: Group, expand: bool | None = None, level: int | None = None) -> Any:
"""Provide a rich display of the hierarchy.

!!! warning "Deprecated"
`zarr.tree()` is deprecated since v3.0.0 and will be removed in a future release.
Use `group.tree()` instead.

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.
"""
return sync(async_api.tree(grp._async_group, expand=expand, level=level))


# TODO: add type annotations for kwargs
def array(data: npt.ArrayLike | AnyArray, **kwargs: Any) -> AnyArray:
"""Create an array filled with `data`.
Expand Down
26 changes: 0 additions & 26 deletions src/zarr/core/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1004,20 +1004,6 @@ def serializer(self) -> ArrayBytesCodec | None:
codec for codec in self.metadata.inner_codecs if isinstance(codec, ArrayBytesCodec)
)

@property
@deprecated("Use AsyncArray.compressors instead.", category=ZarrDeprecationWarning)
def compressor(self) -> Numcodec | None:
"""
Compressor that is applied to each chunk of the array.

!!! warning "Deprecated"
`Array.compressor` is deprecated since v3.0.0 and will be removed in a future release.
Use [`Array.compressors`][zarr.AsyncArray.compressors] instead.
"""
if self.metadata.zarr_format == 2:
return self.metadata.compressor
raise TypeError("`compressor` is not available for Zarr format 3 arrays.")

@property
def compressors(self) -> tuple[Numcodec, ...] | tuple[BytesBytesCodec, ...]:
"""
Expand Down Expand Up @@ -2297,18 +2283,6 @@ def serializer(self) -> ArrayBytesCodec | None:
"""
return self.async_array.serializer

@property
@deprecated("Use Array.compressors instead.", category=ZarrDeprecationWarning)
def compressor(self) -> Numcodec | None:
"""
Compressor that is applied to each chunk of the array.

!!! warning "Deprecated"
`array.compressor` is deprecated since v3.0.0 and will be removed in a future release.
Use [`array.compressors`][zarr.Array.compressors] instead.
"""
return self.async_array.compressor

@property
def compressors(self) -> tuple[Numcodec, ...] | tuple[BytesBytesCodec, ...]:
"""
Expand Down
13 changes: 0 additions & 13 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
ArrayNotFoundError,
ContainsArrayError,
MetadataValidationError,
ZarrDeprecationWarning,
ZarrUserWarning,
)
from zarr.storage import MemoryStore
Expand Down Expand Up @@ -1068,18 +1067,6 @@ def test_load_local(tmp_path: Path, path: str | None, load_read_only: bool) -> N
assert np.array_equal(result, data)


def test_tree() -> None:
g1 = zarr.group()
g1.create_group("foo")
g3 = g1.create_group("bar")
g3.create_group("baz")
g5 = g3.create_group("qux")
g5.create_array("baz", shape=(100,), chunks=(10,), dtype="float64")
with pytest.warns(ZarrDeprecationWarning, match=r"Group\.tree instead\."): # noqa: PT031
assert repr(zarr.tree(g1)) == repr(g1.tree())
assert str(zarr.tree(g1)) == str(g1.tree())


# @pytest.mark.parametrize("stores_from_path", [False, True])
# @pytest.mark.parametrize(
# "with_chunk_store,listable",
Expand Down
6 changes: 3 additions & 3 deletions tests/test_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ def test_create_array_defaults(store: Store) -> None:
g = zarr.open(store, mode="w", zarr_format=2)
assert isinstance(g, Group)
arr = g.create_array("one", dtype="i8", shape=(1,), chunks=(1,), compressor=None)
assert arr.async_array.compressor is None
assert arr.compressors == ()
assert not (arr.filters)
arr = g.create_array("two", dtype="i8", shape=(1,), chunks=(1,))
assert arr.async_array.compressor is not None
assert arr.compressors != ()
assert not (arr.filters)
arr = g.create_array("three", dtype="i8", shape=(1,), chunks=(1,), compressor=Zstd())
assert arr.async_array.compressor is not None
assert arr.compressors != ()
assert not (arr.filters)
with pytest.raises(ValueError):
g.create_array(
Expand Down
Loading