SChunk.iterchunks_info#

SChunk.iterchunks_info() Iterator[info]#

Iterate over the chunks of the SChunk, providing info on index and special values.

Yields:

info (namedtuple) –

A namedtuple with the following fields:

nchunk: int

The index of the chunk.

cratio: float

The compression ratio of the chunk.

special: SpecialValue

The special value enum of the chunk; if 0, the chunk is not special.

repeated_value: bytes or None

The repeated value for the chunk; if not SpecialValue.VALUE, it is None.

lazychunk: bytes

A buffer with the complete lazy chunk.

Examples

>>> import blosc2
>>> import numpy as np
>>> # Create sample data and an SChunk
>>> data = np.arange(400 * 1000, dtype=np.int32)
>>> cparams = blosc2.CParams(typesize=4)
>>> schunk = blosc2.SChunk(data=data, cparams=cparams)
>>> # Iterate over chunks and print detailed information
>>> for chunk_info in schunk.iterchunks_info():
>>>     f"Chunk index: {chunk_info.nchunk}"
>>>     f"Compression ratio: {chunk_info.cratio:.2f}"
>>>     f"Special value: {chunk_info.special.name}"
>>>     f"Repeated value: {chunk_info.repeated_value[:10] if chunk_info.repeated_value else None}"
Chunk index: 0
Compression ratio: 223.56
Special value: NOT_SPECIAL
Repeated value: None