From 8a93077d1473684e875f433ad94ebc5034a3480d Mon Sep 17 00:00:00 2001 From: Norman Rzepka Date: Mon, 6 Jan 2025 09:18:27 +0100 Subject: [PATCH 1/2] don't persist the checksum param if false --- numcodecs/zstd.pyx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/numcodecs/zstd.pyx b/numcodecs/zstd.pyx index efd12fa2..c3923596 100644 --- a/numcodecs/zstd.pyx +++ b/numcodecs/zstd.pyx @@ -258,6 +258,13 @@ class Zstd(Codec): self.level) return r + # Override to remove "checksum" if False + def get_config(self): + config = {'id': self.codec_id, 'level': self.level} + if self.checksum: + config['checksum'] = True + return config + @classmethod def default_level(cls): """Returns the default compression level of the underlying zstd library.""" From 93584afd4fb85c14f146d19c35f2b04415eb03f4 Mon Sep 17 00:00:00 2001 From: Norman Rzepka Date: Mon, 6 Jan 2025 09:23:58 +0100 Subject: [PATCH 2/2] add test --- numcodecs/tests/test_zstd.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/numcodecs/tests/test_zstd.py b/numcodecs/tests/test_zstd.py index de42d9e1..fb9d77bc 100644 --- a/numcodecs/tests/test_zstd.py +++ b/numcodecs/tests/test_zstd.py @@ -90,3 +90,10 @@ def test_native_functions(): assert Zstd.default_level() == 3 assert Zstd.min_level() == -131072 assert Zstd.max_level() == 22 + + +def test_zstd_config(): + # Testing that checksum is removed from config if False + codec = Zstd(level=5, checksum=False) + config = codec.get_config() + assert config == {"id": "zstd", "level": 5}