diff --git a/docs/release.rst b/docs/release.rst index 4402ad15..71b1407e 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -52,6 +52,8 @@ Fixes and a warning if the version was incompatible with `zfpy`. This check has been removed because `zfpy` now supports the newer versions of `NumPy`. By :user:`Meher Gajula `, :issue:`672` +* Remove redundant ``id`` from codec metadata serialization in Zarr3 codecs. + By :user:`Norman Rzepka `, :issue:`685` Improvements ~~~~~~~~~~~~ diff --git a/numcodecs/json.py b/numcodecs/json.py index dc52e1a4..72ddb025 100644 --- a/numcodecs/json.py +++ b/numcodecs/json.py @@ -68,7 +68,7 @@ def __init__( def encode(self, buf): try: buf = np.asarray(buf) - except ValueError: + except ValueError: # pragma: no cover buf = np.asarray(buf, dtype=object) items = np.atleast_1d(buf).tolist() items.append(buf.dtype.str) diff --git a/numcodecs/tests/test_zarr3.py b/numcodecs/tests/test_zarr3.py index 1d2749d9..a40b658f 100644 --- a/numcodecs/tests/test_zarr3.py +++ b/numcodecs/tests/test_zarr3.py @@ -225,11 +225,11 @@ def test_generic_bytes_codec( ): try: codec_class()._codec # noqa: B018 - except ValueError as e: + except ValueError as e: # pragma: no cover if "codec not available" in str(e): pytest.xfail(f"{codec_class.codec_name} is not available: {e}") else: - raise # pragma: no cover + raise except ImportError as e: # pragma: no cover pytest.xfail(f"{codec_class.codec_name} is not available: {e}") @@ -272,3 +272,8 @@ def test_delta_astype(store: StorePath): def test_repr(): codec = numcodecs.zarr3.LZ4(level=5) assert repr(codec) == "LZ4(codec_name='numcodecs.lz4', codec_config={'level': 5})" + + +def test_to_dict(): + codec = numcodecs.zarr3.LZ4(level=5) + assert codec.to_dict() == {"name": "numcodecs.lz4", "configuration": {"level": 5}} diff --git a/numcodecs/zarr3.py b/numcodecs/zarr3.py index e3e98935..78293514 100644 --- a/numcodecs/zarr3.py +++ b/numcodecs/zarr3.py @@ -112,6 +112,7 @@ def from_dict(cls, data: dict[str, JSON]) -> Self: def to_dict(self) -> dict[str, JSON]: codec_config = self.codec_config.copy() + codec_config.pop("id", None) return { "name": self.codec_name, "configuration": codec_config,