blosc2.compute_chunks_blocks

blosc2.compute_chunks_blocks(shape: tuple | list, chunks: tuple | list | None = None, blocks: tuple | list | None = None, dtype: ~numpy.dtype = <class 'numpy.uint8'>, **kwargs: dict) → tuple[source]

Compute educated guesses for chunks and blocks of a NDArray.

Parameters:
  • shape (tuple or list) – The shape of the array.

  • chunks (tuple or list) – The shape of the chunk. If None, a guess is computed based on cache sizes and heuristics.

  • blocks (tuple or list) – The shape of the block. Explicit values are preserved, and automatic chunks are chosen as multiples of these blocks. If None, a guess is computed based on cache sizes and heuristics.

  • dtype (np.dtype) – The dtype of the array. Default is np.uint8.

  • kwargs (dict) – Other keyword arguments supported by the SChunk.__init__ constructor.

Returns:

A (chunks, blocks) tuple containing the computed chunk and block sizes.

Return type:

tuple

Notes

For frame-backed storage (contiguous in-memory storage or any on-disk storage), automatic chunks are enlarged if necessary to keep the chunk offsets payload within the native buffer size limit. Blocks are unchanged. Explicit chunks are never enlarged; an oversized offsets payload raises ValueError instead. Padded chunk sizes must also fit within blosc2.MAX_BUFFERSIZE.