Skip to content

Commit 30155c7

Browse files
normanrzdstansby
andauthored
Remove id from zarr3 config serialization (#685)
* Remove id from zarr3 config serialization * add test * tests * release docs --------- Co-authored-by: David Stansby <dstansby@gmail.com>
1 parent 7ed1ace commit 30155c7

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

docs/release.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ Fixes
5353
and a warning if the version was incompatible with `zfpy`.
5454
This check has been removed because `zfpy` now supports the newer versions of `NumPy`.
5555
By :user:`Meher Gajula <me-her>`, :issue:`672`
56+
* Remove redundant ``id`` from codec metadata serialization in Zarr3 codecs.
57+
By :user:`Norman Rzepka <normanrz>`, :issue:`685`
5658

5759
Improvements
5860
~~~~~~~~~~~~

numcodecs/json.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def __init__(
6868
def encode(self, buf):
6969
try:
7070
buf = np.asarray(buf)
71-
except ValueError:
71+
except ValueError: # pragma: no cover
7272
buf = np.asarray(buf, dtype=object)
7373
items = np.atleast_1d(buf).tolist()
7474
items.append(buf.dtype.str)

numcodecs/tests/test_zarr3.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,11 @@ def test_generic_bytes_codec(
225225
):
226226
try:
227227
codec_class()._codec # noqa: B018
228-
except ValueError as e:
228+
except ValueError as e: # pragma: no cover
229229
if "codec not available" in str(e):
230230
pytest.xfail(f"{codec_class.codec_name} is not available: {e}")
231231
else:
232-
raise # pragma: no cover
232+
raise
233233
except ImportError as e: # pragma: no cover
234234
pytest.xfail(f"{codec_class.codec_name} is not available: {e}")
235235

@@ -272,3 +272,8 @@ def test_delta_astype(store: StorePath):
272272
def test_repr():
273273
codec = numcodecs.zarr3.LZ4(level=5)
274274
assert repr(codec) == "LZ4(codec_name='numcodecs.lz4', codec_config={'level': 5})"
275+
276+
277+
def test_to_dict():
278+
codec = numcodecs.zarr3.LZ4(level=5)
279+
assert codec.to_dict() == {"name": "numcodecs.lz4", "configuration": {"level": 5}}

numcodecs/zarr3.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def from_dict(cls, data: dict[str, JSON]) -> Self:
112112

113113
def to_dict(self) -> dict[str, JSON]:
114114
codec_config = self.codec_config.copy()
115+
codec_config.pop("id", None)
115116
return {
116117
"name": self.codec_name,
117118
"configuration": codec_config,

0 commit comments

Comments
 (0)