Filters#
A column’s storage pipeline, mirroring HDF5’s chunk filter pipeline. The
filters and storage chapter covers usage and the
hdf5plugin ecosystem.
- class h5col.FilterPipeline(filters: Iterable[Any] = ())[source]#
An ordered, immutable sequence of
Filterentries.Accepts
Filterinstances andhdf5pluginfilter objects, adapting the latter automatically.- Raises:
FilterError – If an entry is neither a
Filternor anhdf5pluginfilter.
- apply(dcpl: Any) None[source]#
Add every filter, in order, to an HDF5 dataset-creation property list.
- to_h5py_kwargs() dict[str, Any][source]#
Map the pipeline to h5py high-level
create_datasetkeyword arguments.h5py’s high-level dataset API is the only creation path that sets fill values correctly for every dtype (its low-level
set_fill_valueis broken for fixed-length strings), so column creation goes through it. The builtin shuffle/fletcher32 filters map to their boolean keywords and the single remaining compressor maps tocompression/compression_opts.Raises
FilterErrorif the pipeline needs more than one compressor filter, which the high-level API cannot express (combine them into a Blosc/Blosc2 meta-compressor, or drive the low-level DCPL viaapply()).
- class h5col.Filter(plugin_id: int, cd_values: tuple[int, ...] = (), optional: bool = False, name: str = '')[source]#
One entry of a filter pipeline.
- Parameters:
plugin_id (int) – The registered HDF5 filter plugin identifier. A filter plugin is the piece of software that connects the HDF5 library to the code that actually filters a chunk’s bytes.
cd_values (tuple[int, ...]) – Client data (the filter’s unsigned-int parameters), in order.
optional (bool) – If True, HDF5 may skip the filter for a chunk it cannot process instead of failing the write (the
H5Z_FLAG_OPTIONALflag).name (str) – Human-readable label (informational only).
- h5col.Deflate(level: int = 4) Filter[source]#
The built-in deflate compression filter (HDF5’s
H5Z_FILTER_DEFLATE).- Parameters:
level – Compression level,
0–9(default4).- Raises:
FilterError – If level is outside
0–9.
- h5col.from_hdf5plugin(obj: Any) Filter[source]#
Adapt an
hdf5pluginfilter instance to aFilter.hdf5pluginfilter objects behave like mappings of h5py create_dataset keyword arguments (compression= filter id,compression_opts= client data) and expose afilter_idattribute.- Raises:
FilterError – If obj cannot be interpreted as an
hdf5pluginfilter or carries no filter id.