Updated Zstd plugin; Added support for negative compression levels to Zstd#395
Conversation
| raise ValueError( | ||
| f"clevel must be in the range [{self._ZSTD_MIN_CLEVEL}, {self._ZSTD_MAX_CLEVEL}]" | ||
| ) | ||
| clevel_uint32 = struct.unpack("I", struct.pack("i", clevel))[0] |
There was a problem hiding this comment.
Need to pass uint32. The filter cast this back to int
There was a problem hiding this comment.
And we are agree that it is cast the same way ?
clevel = -12
clevel_uint32 = struct.unpack("I", struct.pack("i", clevel))[0]
struct.unpack("i", struct.pack("I", clevel_uint32))[0]
>> -12Could we add a comment on this. Because indeed this is a bit tricky and better to highlight that this is done on purpose...
There was a problem hiding this comment.
I hesitated to make helper functions to make it more explicit.
There was a problem hiding this comment.
To be honest I saw the reverse function a couple of line after but I let the comment.
This is super simple I agree but I would be in favor of helper function (This is easier to test and to associate).
There was a problem hiding this comment.
Added _to_uint32 and _from_uint32 helpers in 58afed3
e594958 to
1b83200
Compare
| raise ValueError( | ||
| f"clevel must be in the range [{self._ZSTD_MIN_CLEVEL}, {self._ZSTD_MAX_CLEVEL}]" | ||
| ) | ||
| clevel_uint32 = struct.unpack("I", struct.pack("i", clevel))[0] |
There was a problem hiding this comment.
And we are agree that it is cast the same way ?
clevel = -12
clevel_uint32 = struct.unpack("I", struct.pack("i", clevel))[0]
struct.unpack("i", struct.pack("I", clevel_uint32))[0]
>> -12Could we add a comment on this. Because indeed this is a bit tricky and better to highlight that this is done on purpose...
1b83200 to
58afed3
Compare
! Merge PR #394 first !
This PR changes upstream project for the Zstd filter from the initial repository (ttps://github.com/aparamon/HDF5Plugin-Zstandard) to the version hosted by the hdfgroup organisation (https://github.com/HDFGroup/hdf5_plugins).
The reason is that the former project is stalled while the later is actively maintained.
For instance, support for negative compression levels (favor speed over compression ratio) as initially proposed in #165 is implemented in the hdfgroup's version of the filter.
This PR also adds support for negative compression levels in
hdf5plugin.Zstdclass.