blosc2.asarray#

blosc2.asarray(array: ndarray | C2Array, **kwargs: dict | list) NDArray#

Convert the array to an NDArray.

Parameters:
  • array (array_like) – An array supporting numpy array interface.

  • kwargs (dict, optional) – Keyword arguments that are supported by the empty() constructor.

Returns:

out – An new NDArray made of array.

Return type:

NDArray

Note

This will create the NDArray chunk-by-chunk directly from the input array, without the need to create a contiguous NumPy array internally. This can be used for ingesting e.g. disk or network based arrays very effectively and without consuming lots of memory.

Examples

>>> import blosc2
>>> import numpy as np
>>> # Create some data
>>> shape = [25, 10]
>>> a = np.arange(0, np.prod(shape), dtype=np.int64).reshape(shape)
>>> # Create a NDArray from a NumPy array
>>> nda = blosc2.asarray(a)