blosc2.register_filter#
- blosc2.register_filter(id, forward=None, backward=None, name=None)#
Register an user defined filter.
- Parameters:
id¶ (int) – Filter id, must be between 160 and 255 (both included).
forward¶ (Python function) – This will receive an input to apply the filter as a ndarray of dtype uint8, an output to fill as a ndarray of dtype uint8, the filter meta and the corresponding SChunk instance. If None then the filter name indicates a dynamic plugin which must be installed.
backward¶ (Python function) – This will receive an input as a ndarray of dtype uint8, an output to fill as a ndarray of dtype uint8, the filter meta and the SChunk instance. If None then the filter name indicates a dynamic plugin which must be installed.
name¶ (str) – The filter name. If both forward`and `backward are None, this parameter must be passed to correctly load the dynamic filter.
- Returns:
out
- Return type:
None
Notes
Cannot use multi-threading when using an user defined filter.
User defined filters can only be used inside a SChunk instance.
See also
Examples
# Define forward and backward functions def forward(input, output, meta, schunk): nd_input = input.view(dtype) nd_output = output.view(dtype) nd_output[:] = nd_input + 1 def backward(input, output, meta, schunk): nd_input = input.view(dtype) nd_output = output.view(dtype) nd_output[:] = nd_input - 1 # Register filter id = 160 blosc2.register_filter(id, forward, backward)