blosc2.LazyArray.compute#
- abstract LazyArray.compute(item: slice | list[slice] | None = None, **kwargs: Any) NDArray #
Return an NDArray containing the evaluation of the LazyArray.
- Parameters:
- Returns:
out – A NDArray containing the result of evaluating the Utilities or LazyExpr.
- Return type:
Notes
If self is a LazyArray from an udf, the kwargs used to store the resulting array will be the ones passed to the constructor in
lazyudf()
(except the urlpath) updated with the kwargs passed when calling this method.
Examples
>>> import blosc2 >>> import numpy as np >>> dtype = np.float64 >>> shape = [3, 3] >>> size = shape[0] * shape[1] >>> a = np.linspace(0, 5, num=size, dtype=dtype).reshape(shape) >>> b = np.linspace(0, 5, 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 >>> output = expr.compute() >>> f"Result of a + b (lazy evaluation): {output[:]}" Result of a + b (lazy evaluation): [[ 0. 1.25 2.5 ] [ 3.75 5. 6.25] [ 7.5 8.75 10. ]]