Skip to content

Zstd: Don't persist the checksum param if false #681

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

Closed
wants to merge 2 commits into from
Closed
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
7 changes: 7 additions & 0 deletions numcodecs/tests/test_zstd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
7 changes: 7 additions & 0 deletions numcodecs/zstd.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
Loading