Skip to content

Commit

Permalink
Merge pull request #164 from mkitti/zstd_clevel
Browse files Browse the repository at this point in the history
Add clevel argument for Zstd
  • Loading branch information
t20100 authored May 3, 2022
2 parents 505aad8 + cbf3870 commit 6aeb14c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/hdf5plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,25 @@ class Zstd(_FilterRefClass):
data=numpy.arange(100),
**hdf5plugin.Zstd())
f.close()
:param int clevel: Compression level from 1 (lowest compression) to 22 (maximum compression).
Ultra compression extends from 20 through 22. Default: 3.
.. code-block:: python
f = h5py.File('test.h5', 'w')
f.create_dataset(
'zstd',
data=numpy.arange(100),
**hdf5plugin.Zstd(clevel=22))
f.close()
"""
filter_id = ZSTD_ID

def __init__(self, clevel=3):
assert 1 <= clevel <= 22
self.filter_options = (clevel,)


def _init_filters():
"""Initialise and register HDF5 filters with h5py
Expand Down
10 changes: 10 additions & 0 deletions src/hdf5plugin/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@ def testZfp(self):
def testZstd(self):
"""Write/read test with Zstd filter plugin"""
self._test('zstd')
tests = [
{'clevel': 3},
{'clevel': 22}
]
for options in tests:
for dtype in (numpy.float32, numpy.float64):
with self.subTest(options=options, dtype=dtype):
self._test('zstd', dtype=dtype, **options)




class TestPackage(unittest.TestCase):
Expand Down

0 comments on commit 6aeb14c

Please sign in to comment.