SChunk.decompress_chunk#

SChunk.decompress_chunk(nchunk, dst=None)#

Decompress the chunk given by its index nchunk.

Parameters:
  • nchunk (int) – The index of the chunk that will be decompressed.

  • dst (NumPy object or bytearray) – The destination NumPy object or bytearray to fill, the length of which must be greater than 0. The user must make sure that it has enough capacity for hosting the decompressed chunk. Default is None, meaning that a new bytes object is created, filled and returned.

Returns:

out – The decompressed chunk in form of a Python str / bytes object if dst is None. Otherwise, it will return None because the result will already be in dst.

Return type:

str/bytes

Raises:

RunTimeError – If some problem was detected.

Examples

>>> import blosc2
>>> cparams = {'typesize': 1}
>>> storage = {'cparams': cparams}
>>> schunk = blosc2.SChunk(chunksize=11, **storage)
>>> buffer = b"wermqeoir23"
>>> schunk.append_data(buffer)
1
>>> schunk.decompress_chunk(0)
b'wermqeoir23'
>>> bytes_obj = bytearray(len(buffer))
>>> schunk.decompress_chunk(0, dst=bytes_obj)
>>> bytes_obj == buffer
True