Skip to content

Commit 02e5f65

Browse files
committed
LazyArray.compute() should honor out= param. Fixes #503
1 parent 1cf11f6 commit 02e5f65

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/blosc2/lazyexpr.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2822,6 +2822,7 @@ def compute(self, item=(), **kwargs) -> blosc2.NDArray:
28222822
# When NumPy ufuncs are called, the user may add an `out` parameter to kwargs
28232823
if "out" in kwargs:
28242824
kwargs["_output"] = kwargs.pop("out")
2825+
self._output = kwargs["_output"]
28252826
if hasattr(self, "_output"):
28262827
kwargs["_output"] = self._output
28272828
if "ne_args" in kwargs:

tests/ndarray/test_lazyexpr.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,3 +1727,12 @@ def test_lazylinalg():
17271727
npres = np.matmul(npA, npB)
17281728
assert out.shape == npres.shape
17291729
np.testing.assert_array_almost_equal(out[()], npres)
1730+
1731+
1732+
# Test for issue #503 (LazyArray.compute() should honor out param)
1733+
def test_lazyexpr_compute_out():
1734+
a = blosc2.ones(10)
1735+
out = blosc2.zeros(1)
1736+
lexpr = blosc2.lazyexpr("sum(a)")
1737+
assert lexpr.compute(out=out) is out
1738+
assert out[0] == 10

0 commit comments

Comments
 (0)