blosc2.schunk.SChunk.filler#
- SChunk.filler(inputs_tuple: tuple[tuple], schunk_dtype: dtype, nelem: int | None = None) None #
Decorator to set a filler function.
This function will fill
self
according tonelem
. It will receive three parameters: a tuple with the inputs as ndarrays from which to read, the ndarray to fillself
and the offset inside the SChunk instance where the corresponding block begins (see example below).- Parameters:
inputs_tuple¶ (tuple of tuples) – Tuple containing a tuple for each argument that the function will receive, along with their corresponding np.dtype. Supported operand types are SChunk, ndarray and Python scalars.
schunk_dtype¶ (np.dtype) – The data type to use to fill
self
.nelem¶ (int) – Number of elements to append to
self
. If None (default) it will be the number of elements from the operands.
- Returns:
out
- Return type:
None
Notes
Compression nthreads must be 1 when using this.
This does not need to be removed from the created SChunk instance.
See also
Examples
# Set the compression and decompression parameters schunk_dtype = np.dtype(np.float64) cparams = blosc2.CParams(typesize=schunk_dtype.itemsize, nthreads=1) # Create empty SChunk schunk = blosc2.SChunk(chunksize=20_000 * schunk_dtype.itemsize, cparams=cparams) # Create operands op_dtype = np.dtype(np.int32) data = np.full(20_000 * 3, 12, dtype=op_dtype) schunk_op = blosc2.SChunk(chunksize=20_000 * op_dtype.itemsize, data=data) # Create filler @schunk.filler(((schunk_op, op_dtype), (np.e, np.float32)), schunk_dtype) def filler(inputs_tuple, output, offset): output[:] = inputs_tuple[0] - inputs_tuple[1]