Skip to content

Commit 551c960

Browse files
author
Luke Shaw
committed
Add tests to force compute
1 parent bbb9d7e commit 551c960

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

caterva2/tests/test_api.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ def test_expr_no_operand(auth_client):
747747
a = blosc2.linspace(0, 10)
748748
np.testing.assert_array_equal(a[:], c[:])
749749

750-
# Check error when operand should be present but isnt
750+
# Check error when operand should be present but isn't
751751
opnm = "ds"
752752
oppt = f"{TEST_CATERVA2_ROOT}/ds-1d.b2nd"
753753
expression = "ds + linspace(0, 10)"
@@ -758,9 +758,29 @@ def test_expr_no_operand(auth_client):
758758
lxpath = auth_client.lazyexpr(lxname, expression)
759759

760760

761-
# User management
761+
def test_expr_force_compute(auth_client):
762+
if not auth_client:
763+
pytest.skip("authentication support needed")
764+
765+
expression = "linspace(0, 10)"
766+
lxname = "my_expr"
762767

768+
auth_client.subscribe(TEST_CATERVA2_ROOT)
763769

770+
# Uncomputed lazyexpr is a blosc2 lazyexpr
771+
lxpath = auth_client.lazyexpr(lxname, expression, compute=False)
772+
assert lxpath == pathlib.Path(f"@personal/{lxname}.b2nd")
773+
c = auth_client.get(lxpath)
774+
assert c.meta["expression"] == expression
775+
776+
# Computed lazyexpr is a blosc2 array
777+
lxpath = auth_client.lazyexpr(lxname, expression, compute=True)
778+
assert lxpath == pathlib.Path(f"@personal/{lxname}.b2nd")
779+
c = auth_client.get(lxpath)
780+
assert c.meta.get("expression", None) is None
781+
782+
783+
# User management
764784
def test_adduser(auth_client):
765785
if not auth_client:
766786
pytest.skip("authentication support needed")

0 commit comments

Comments
 (0)