Skip to content

Commit

Permalink
Merge pull request #101 from NeurodataWithoutBorders/zlib-compression
Browse files Browse the repository at this point in the history
support zlib compression
  • Loading branch information
magland authored Dec 3, 2024
2 parents a478191 + 90725f8 commit 34769cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lindi/LindiH5pyFile/writers/LindiH5pyGroupWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ def create_dataset(
else:
raise Exception(f'Unexpected type for compression_opts: {type(compression_opts)}')
_zarr_compressor = numcodecs.GZip(level=level)
elif compression == 'zlib':
if compression_opts is None:
level = 4
elif isinstance(compression_opts, int):
level = compression_opts
else:
raise Exception(f'Unexpected type for compression_opts: {type(compression_opts)}')
_zarr_compressor = numcodecs.Zlib(level=level)
else:
raise Exception(f'Compression {compression} is not supported')
elif compression is None:
Expand Down
2 changes: 2 additions & 0 deletions lindi/conversion/h5_filters_to_codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def h5_filters_to_codecs(h5obj: h5py.Dataset) -> Union[List[Codec], None]:
filters.append(numcodecs.Zstd(level=properties[0]))
elif str(filter_id) == "gzip":
filters.append(numcodecs.Zlib(level=properties))
elif str(filter_id) == "zlib":
filters.append(numcodecs.Zlib(level=properties))
elif str(filter_id) == "32004":
raise RuntimeError(
f"{h5obj.name} uses lz4 compression - not supported"
Expand Down

0 comments on commit 34769cd

Please sign in to comment.