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:
item¶ (slice, list of slices, optional) – If provided, item is used to slice the operands prior to computation; not to retrieve specified slices of the evaluated result. This difference between slicing operands and slicing the final expression is important when reductions or a where clause are used in the expression.
kwargs¶ (Any, optional) – Keyword arguments that are supported by the
empty()
constructor. These arguments will be set in the resulting NDArray.
- Returns:
out – A NDArray containing the result of evaluating the LazyUDF 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. ]]