blosc2.unpack_array#

blosc2.unpack_array(packed_array: str | bytes, **kwargs: dict) ndarray#

Restore a packed NumPy array.

Parameters:
  • packed_array (str or bytes) – The packed array to be restored.

  • kwargs (dict, optional) – Parameters that can be passed to the pickle.loads API

Returns:

out – The decompressed data in form of a NumPy array.

Return type:

ndarray

Raises:

TypeError – If packed_array is not of type bytes or string.

Examples

>>> import numpy as np
>>> a = np.arange(1e6)
>>> parray = blosc2.pack_array(a)
>>> len(parray) < a.size*a.itemsize
True
>>> a2 = blosc2.unpack_array(parray)
>>> np.array_equal(a, a2)
True
>>> a = np.array(['å', 'ç', 'ø'])
>>> parray = blosc2.pack_array(a)
>>> a2 = blosc2.unpack_array(parray)
>>> np.array_equal(a, a2)
True