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/3833.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove the warning that is emitted when any Numcodecs codec is instantiated.
8 changes: 0 additions & 8 deletions src/zarr/codecs/numcodecs/_codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
from dataclasses import dataclass, replace
from functools import cached_property
from typing import TYPE_CHECKING, Any, Self
from warnings import warn

import numpy as np

Expand All @@ -41,7 +40,6 @@
from zarr.core.buffer.cpu import as_numpy_array_wrapper
from zarr.core.common import JSON, parse_named_configuration, product
from zarr.dtype import UInt8, ZDType, parse_dtype
from zarr.errors import ZarrUserWarning
from zarr.registry import get_numcodec

if TYPE_CHECKING:
Expand Down Expand Up @@ -102,12 +100,6 @@ def __init__(self, **codec_config: JSON) -> None:
) # pragma: no cover

object.__setattr__(self, "codec_config", codec_config)
warn(
"Numcodecs codecs are not in the Zarr version 3 specification and "
"may not be supported by other zarr implementations.",
category=ZarrUserWarning,
stacklevel=2,
)

@cached_property
def _codec(self) -> Numcodec:
Expand Down
25 changes: 11 additions & 14 deletions tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1853,24 +1853,21 @@ def test_roundtrip_numcodecs() -> None:

# Create the array with the correct codecs
root = zarr.group(store)
warn_msg = "Numcodecs codecs are not in the Zarr version 3 specification and may not be supported by other zarr implementations."
with pytest.warns(ZarrUserWarning, match=warn_msg):
root.create_array(
"test",
shape=(720, 1440),
chunks=(720, 1440),
dtype="float64",
compressors=compressors, # type: ignore[arg-type]
filters=filters, # type: ignore[arg-type]
fill_value=-9.99,
dimension_names=["lat", "lon"],
)
root.create_array(
"test",
shape=(720, 1440),
chunks=(720, 1440),
dtype="float64",
compressors=compressors, # type: ignore[arg-type]
filters=filters, # type: ignore[arg-type]
fill_value=-9.99,
dimension_names=["lat", "lon"],
)

BYTES_CODEC = {"name": "bytes", "configuration": {"endian": "little"}}
# Read in the array again and check compressor config
root = zarr.open_group(store)
with pytest.warns(ZarrUserWarning, match=warn_msg):
metadata = root["test"].metadata.to_dict()
metadata = root["test"].metadata.to_dict()
expected = (*filters, BYTES_CODEC, *compressors)
assert metadata["codecs"] == expected

Expand Down
10 changes: 2 additions & 8 deletions tests/test_cli/test_migrate_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@

runner = typer_testing.CliRunner()

NUMCODECS_USER_WARNING = "Numcodecs codecs are not in the Zarr version 3 specification and may not be supported by other zarr implementations."


def test_migrate_array(local_store: LocalStore) -> None:
shape = (10, 10)
Expand Down Expand Up @@ -316,7 +314,6 @@ def test_migrate_compressor(
assert np.all(zarr_array[:] == 1)


@pytest.mark.filterwarnings(f"ignore:{NUMCODECS_USER_WARNING}:UserWarning")
def test_migrate_numcodecs_compressor(local_store: LocalStore) -> None:
"""Test migration of a numcodecs compressor without a zarr.codecs equivalent."""

Expand Down Expand Up @@ -360,7 +357,6 @@ def test_migrate_numcodecs_compressor(local_store: LocalStore) -> None:
assert np.all(zarr_array[:] == 1)


@pytest.mark.filterwarnings(f"ignore:{NUMCODECS_USER_WARNING}:UserWarning")
def test_migrate_filter(local_store: LocalStore) -> None:
filter_v2 = numcodecs.Delta(dtype="<u2", astype="<u2")
filter_v3 = Delta(dtype="<u2", astype="<u2")
Expand Down Expand Up @@ -524,8 +520,7 @@ def test_migrate_incorrect_filter(local_store: LocalStore) -> None:
fill_value=0,
)

with pytest.warns(UserWarning, match=NUMCODECS_USER_WARNING):
result = runner.invoke(cli.app, ["migrate", "v3", str(local_store.root)])
result = runner.invoke(cli.app, ["migrate", "v3", str(local_store.root)])

assert result.exit_code == 1
assert isinstance(result.exception, TypeError)
Expand All @@ -548,8 +543,7 @@ def test_migrate_incorrect_compressor(local_store: LocalStore) -> None:
fill_value=0,
)

with pytest.warns(UserWarning, match=NUMCODECS_USER_WARNING):
result = runner.invoke(cli.app, ["migrate", "v3", str(local_store.root)])
result = runner.invoke(cli.app, ["migrate", "v3", str(local_store.root)])

assert result.exit_code == 1
assert isinstance(result.exception, TypeError)
Expand Down
Loading
Loading