Skip to content

Commit e6d602b

Browse files
committed
Add the blosc2.evaluate() too
1 parent 6db5c4e commit e6d602b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

examples/ndarray/xarray-expression.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ def __len__(self):
4444
assert isinstance(b, blosc2.Array) # any Array compliant object works
4545
c = blosc2.asarray(a) # convert into a blosc2.NDArray; data is copied
4646
d = blosc2.SimpleProxy(a) # SimpleProxy conversion; no copies
47+
# Define a lazy expression (defer computation until needed)
4748
lb = blosc2.lazyexpr("a + sin(b) + hypot(c, d) + 1")
4849

4950
# Check!
5051
np.testing.assert_array_equal(lb[:], res)
52+
# One can also evaluate the expression directly (eager computation)
53+
resb2 = blosc2.evaluate("a + sin(b) + hypot(c, d) + 1")
54+
np.testing.assert_array_equal(resb2, res)

0 commit comments

Comments
 (0)