SChunk.iterchunks#

SChunk.iterchunks(dtype: dtype) Iterator[ndarray]#

Iterate over self chunks.

Parameters:

dtype (np.dtype) – The data type to use.

Yields:

chunk (NumPy ndarray) – The decompressed chunk.

Examples

>>> import blosc2
>>> import numpy as np
>>> # Create sample data and an SChunk
>>> data = np.arange(400 * 1000, dtype=np.int32)
>>> schunk = blosc2.SChunk(data=data, cparams={"typesize": 4})
>>> # Iterate over chunks using the iterchunks method
>>> for chunk in schunk.iterchunks(dtype=np.int32):
>>>     f"Chunk shape: {chunk.shape} "
>>>     f"First 5 elements of chunk: {chunk[:5]}"
Chunk shape: (400000,)
First 5 elements of chunk: [0 1 2 3 4]