Skip to content

Remove id from zarr3 config serialization #685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 17, 2025
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
2 changes: 2 additions & 0 deletions docs/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <me-her>`, :issue:`672`
* Remove redundant ``id`` from codec metadata serialization in Zarr3 codecs.
By :user:`Norman Rzepka <normanrz>`, :issue:`685`

Improvements
~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion numcodecs/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions numcodecs/tests/test_zarr3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down Expand Up @@ -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}}
1 change: 1 addition & 0 deletions numcodecs/zarr3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading