blosc2.pack_array¶
- blosc2.pack_array(arr: ndarray, clevel: int = 9, filter: Filter = Filter.SHUFFLE, codec: Codec = Codec.BLOSCLZ) str | bytes[source]¶
Pack (compress) a NumPy array. It is equivalent to the pack function.
- Parameters:
arr¶ (np.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 applied during compression. The default isFilter.SHUFFLE.codec¶ (
Codec(optional)) – The codec to be used for compression. The default isCodec.BLOSCLZ.
- Returns:
out – The packed array in the form of a Python str or bytes object.
- Return type:
str or bytes
- Raises:
AttributeError – If
arrdoes not have an itemsize attribute. Ifarrdoes 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
clevelis not within the allowed range. Ifcodecis 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