From 926c54e9c69c90015136e07a16b8d4a0cbc3fa67 Mon Sep 17 00:00:00 2001 From: Norman Rzepka Date: Thu, 9 Jan 2025 10:07:10 +0100 Subject: [PATCH 1/4] Remove id from zarr3 config serialization --- numcodecs/zarr3.py | 1 + 1 file changed, 1 insertion(+) 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, From f102e84b4d8ed2b52ea4eb13e0187bb67abf265d Mon Sep 17 00:00:00 2001 From: Norman Rzepka Date: Thu, 9 Jan 2025 10:13:00 +0100 Subject: [PATCH 2/4] add test --- numcodecs/tests/test_zarr3.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/numcodecs/tests/test_zarr3.py b/numcodecs/tests/test_zarr3.py index 1d2749d9..b9251efa 100644 --- a/numcodecs/tests/test_zarr3.py +++ b/numcodecs/tests/test_zarr3.py @@ -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}} From 57ec320c3457f9fb712a8dc9965ac10d7c72c622 Mon Sep 17 00:00:00 2001 From: Norman Rzepka Date: Thu, 9 Jan 2025 10:37:11 +0100 Subject: [PATCH 3/4] tests --- numcodecs/tests/test_zarr3.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numcodecs/tests/test_zarr3.py b/numcodecs/tests/test_zarr3.py index b9251efa..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}") From 0236ca3ac18dadebd3d1c40a17411ca3b680bc42 Mon Sep 17 00:00:00 2001 From: Norman Rzepka Date: Thu, 9 Jan 2025 11:00:51 +0100 Subject: [PATCH 4/4] release docs --- docs/release.rst | 2 ++ numcodecs/json.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/release.rst b/docs/release.rst index 5c8f83b9..fec8cf4a 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -48,6 +48,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)