blosc2.fromiter#

blosc2.fromiter(iterable, shape, dtype, c_order=True, **kwargs) NDArray#

Create a new array from an iterable object.

Parameters:
  • iterable (iterable) – An iterable object providing data for the array.

  • shape (int, tuple or list) – The shape of the final array.

  • dtype (np.dtype or list str) – The data type of the array elements in NumPy format.

  • c_order (bool) – Whether to store the array in C order (row-major) or insertion order. Insertion order means that iterable values will be stored in the array following the order of chunks in the array; this is more memory efficient, as it does not require an intermediate copy of the array. Default is C order.

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

Returns:

out – A NDArray is returned.

Return type:

NDArray

Examples

>>> import blosc2
>>> import numpy as np
>>> # Create an array from an iterable
>>> array = blosc2.fromiter(range(10), shape=(10,), dtype=np.int64)
>>> print(array[:])
[0 1 2 3 4 5 6 7 8 9]