blosc2.pack_array#
- blosc2.pack_array(arr, clevel=9, filter=Filter.SHUFFLE, codec=Codec.BLOSCLZ)#
Pack (compress) a NumPy array. It is equivalent to the pack function.
- Parameters:
arr¶ (ndarray) – The NumPy array to be packed.
clevel¶ (int (optional)) – The compression level from 0 (no compression) to 9 (maximum compression). The default is 9.
filter¶ (
Filter
(optional)) – The filter to be activated. The default isFilter.SHUFFLE
.codec¶ (
Codec
(optional)) – The compressor used internally in Blosc. The default isCodec.BLOSCLZ
.
- Returns:
out – The packed array in form of a Python str / bytes object.
- Return type:
str / bytes
- Raises:
AttributeError – If
arr
does not have an itemsize attribute. Ifarr
does not have a size attribute.ValueError – If typesize is not within the allowed range. If the pickled object size is larger than the maximum allowed buffer size. If
clevel
is not within the allowed range. Ifcodec
is not within the supported compressors.
See also
Examples
>>> import numpy as np >>> a = np.arange(1e6) >>> parray = blosc2.pack_array(a) >>> len(parray) < a.size*a.itemsize True