blosc2.unpack_array#

blosc2.unpack_array(packed_array, **kwargs)#

Unpack (decompress) a packed NumPy array.

Parameters:
  • packed_array (str / bytes) – The packed array to be decompressed.

  • **kwargs (fix_imports / encoding / errors) – 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
>>> a = numpy.arange(1e6)
>>> parray = blosc2.pack_array(a)
>>> len(parray) < a.size*a.itemsize
True
>>> a2 = blosc2.unpack_array(parray)
>>> numpy.array_equal(a, a2)
True
>>> a = numpy.array(['å', 'ç', 'ø'])
>>> parray = blosc2.pack_array(a)
>>> a2 = blosc2.unpack_array(parray)
>>> numpy.array_equal(a, a2)
True