Skip to content

Commit a6b2458

Browse files
author
Luke Shaw
committed
Add documentation of behaviour of get_item and compute for LazyExprs
1 parent 1333dae commit a6b2458

File tree

1 file changed

+5
-28
lines changed

1 file changed

+5
-28
lines changed

src/blosc2/lazyexpr.py

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ def compute(self, item: slice | list[slice] | None = None, **kwargs: Any) -> blo
279279
----------
280280
item: slice, list of slices, optional
281281
If not None, only the chunks that intersect with the slices
282-
in items will be evaluated.
282+
in item will be evaluated. If provided, items of the operands to be used in computation.
283+
Important to note that item is used to slice the operands PRIOR to computation.
283284
284285
kwargs: Any, optional
285286
Keyword arguments that are supported by the :func:`empty` constructor.
@@ -328,7 +329,9 @@ def __getitem__(self, item: int | slice | Sequence[slice]) -> blosc2.NDArray:
328329
Parameters
329330
----------
330331
item: int, slice or sequence of slices
331-
The slice(s) to be retrieved. Note that step parameter is not yet honored.
332+
If provided, items of the operands to be used in computation.
333+
Important to note that item is used to slice the operands PRIOR to computation, not to retrieve specified
334+
slices of the evaluated result.
332335
333336
Returns
334337
-------
@@ -2689,21 +2692,6 @@ def sort(self, order: str | list[str] | None = None) -> blosc2.LazyArray:
26892692
return lazy_expr
26902693

26912694
def compute(self, item=None, **kwargs) -> blosc2.NDArray:
2692-
"""
2693-
Compute the expression with the given item and kwargs.
2694-
Parameters
2695-
----------
2696-
item: int, slice or sequence of slices, optional
2697-
The slice(s) of the operands to be used in computation. Note that step parameter is not honored yet.
2698-
Item is used to slice the operands PRIOR to computation.
2699-
kwargs
2700-
2701-
Returns:
2702-
blosc2.NDArray or numpy.ndarray
2703-
-------
2704-
2705-
"""
2706-
27072695
# When NumPy ufuncs are called, the user may add an `out` parameter to kwargs
27082696
if "out" in kwargs:
27092697
kwargs["_output"] = kwargs.pop("out")
@@ -2738,17 +2726,6 @@ def compute(self, item=None, **kwargs) -> blosc2.NDArray:
27382726
return result
27392727

27402728
def __getitem__(self, item):
2741-
"""
2742-
Apply LazyExpr on a slice of the oeprands.
2743-
Parameters
2744-
----------
2745-
item: int, slice or sequence of slices, optional
2746-
The slice(s) of the operands to be used in computation. Note that step parameter is not honored yet.
2747-
Item is used to slice the operands PRIOR to computation.
2748-
Returns:
2749-
numpy.ndarray
2750-
"""
2751-
27522729
kwargs = {"_getitem": True}
27532730
return self.compute(item, **kwargs)
27542731

0 commit comments

Comments
 (0)