Skip to content

Commit 9057c20

Browse files
committed
Fix compute for LazyUDF
1 parent 33d6a5f commit 9057c20

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/blosc2/lazyexpr.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,13 @@ def validate_inputs(inputs: dict, out=None, reduce=False) -> tuple: # noqa: C90
886886
return shape, None, None, False
887887

888888
# More checks specific of NDArray inputs
889-
NDinputs = [input for input in inputs if hasattr(input, "chunks")]
889+
# NDInputs are either non-SimpleProxy with chunks or are SimpleProxy with src having chunks
890+
NDinputs = [
891+
input
892+
for input in inputs
893+
if (hasattr(input, "chunks") and not isinstance(input, blosc2.SimpleProxy))
894+
or (isinstance(input, blosc2.SimpleProxy) and hasattr(input.src, "chunks"))
895+
]
890896
if not NDinputs:
891897
# All inputs are NumPy arrays, so we cannot take the fast path
892898
if inputs and hasattr(inputs[0], "shape"):

src/blosc2/proxy.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,11 @@ def __getitem__(self, item: slice | list[slice]) -> np.ndarray:
667667
out: numpy.ndarray
668668
An array with the data slice.
669669
"""
670-
return np.asarray(self._src[item]) # avoids copy for PyTorch at least
670+
out = self._src[item]
671+
if not hasattr(out, "shape") or out.shape == ():
672+
return out
673+
else:
674+
return np.asarray(out) # avoids copy for PyTorch at least
671675

672676

673677
def as_simpleproxy(x: blosc2.Array) -> SimpleProxy | blosc2.Operand:

0 commit comments

Comments
 (0)