blosc2.LazyArray.__getitem__#

abstract LazyArray.__getitem__(item: int | slice | Sequence[slice]) blosc2.NDArray#

Return a NumPy.ndarray containing the evaluation of the LazyArray.

Parameters:

item (int, slice or sequence of slices) – The slice(s) to be retrieved. Note that step parameter is not yet honored.

Returns:

out – An array with the data containing the evaluated slice.

Return type:

np.ndarray

Examples

>>> import blosc2
>>> import numpy as np
>>> dtype = np.float64
>>> shape = [30, 4]
>>> size = shape[0] * shape[1]
>>> a = np.linspace(0, 10, num=size, dtype=dtype).reshape(shape)
>>> b = np.linspace(0, 10, num=size, dtype=dtype).reshape(shape)
>>> #  Convert numpy arrays to Blosc2 arrays
>>> a1 = blosc2.asarray(a)
>>> b1 = blosc2.asarray(b)
>>> # Perform the mathematical operation
>>> expr = a1 + b1  # LazyExpr expression
>>> expr[3]
[2.01680672 2.18487395 2.35294118 2.5210084 ]
>>> expr[2:4]
[[1.34453782 1.51260504 1.68067227 1.8487395 ]
[2.01680672 2.18487395 2.35294118 2.5210084 ]]