@@ -655,7 +655,7 @@ def test_lazyexpr(auth_client):
655
655
lxinfo = auth_client .get_info (lxpath )
656
656
assert lxinfo ["shape" ] == opinfo ["shape" ]
657
657
assert lxinfo ["dtype" ] == opinfo ["dtype" ]
658
- assert lxinfo ["expression" ] == f"{ expression } "
658
+ assert lxinfo ["expression" ] == f"( { expression } ) "
659
659
assert lxinfo ["operands" ] == operands
660
660
661
661
# Check result data.
@@ -720,8 +720,8 @@ def test_expr_from_expr(auth_client):
720
720
lxinfo2 = auth_client .get_info (lxpath2 )
721
721
assert lxinfo ["shape" ] == opinfo ["shape" ] == lxinfo2 ["shape" ]
722
722
assert lxinfo ["dtype" ] == opinfo ["dtype" ] == lxinfo2 ["dtype" ]
723
- assert lxinfo ["expression" ] == f"{ expression } "
724
- assert lxinfo2 ["expression" ] == f"{ expression2 } "
723
+ assert lxinfo ["expression" ] == f"( { expression } ) "
724
+ assert lxinfo2 ["expression" ] == f"( { expression2 } ) "
725
725
assert lxinfo ["operands" ] == operands
726
726
assert lxinfo2 ["operands" ] == operands2
727
727
@@ -733,9 +733,54 @@ def test_expr_from_expr(auth_client):
733
733
np .testing .assert_array_equal ((a [:] + 1 ) * 2 , c [:])
734
734
735
735
736
- # User management
736
+ def test_expr_no_operand (auth_client ):
737
+ if not auth_client :
738
+ pytest .skip ("authentication support needed" )
739
+
740
+ expression = "linspace(0, 10)"
741
+ lxname = "my_expr"
742
+
743
+ auth_client .subscribe (TEST_CATERVA2_ROOT )
744
+ lxpath = auth_client .lazyexpr (lxname , expression )
745
+ assert lxpath == pathlib .Path (f"@personal/{ lxname } .b2nd" )
746
+ c = auth_client .get (lxpath )
747
+ a = blosc2 .linspace (0 , 10 )
748
+ np .testing .assert_array_equal (a [:], c [:])
749
+
750
+ # Check error when operand should be present but isn't
751
+ opnm = "ds"
752
+ oppt = f"{ TEST_CATERVA2_ROOT } /ds-1d.b2nd"
753
+ expression = "ds + linspace(0, 10)"
754
+ lxname = "my_expr"
755
+
756
+ auth_client .subscribe (TEST_CATERVA2_ROOT )
757
+ with pytest .raises (Exception ) as e_info :
758
+ lxpath = auth_client .lazyexpr (lxname , expression )
759
+
760
+
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"
737
767
768
+ auth_client .subscribe (TEST_CATERVA2_ROOT )
769
+
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
738
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
739
784
def test_adduser (auth_client ):
740
785
if not auth_client :
741
786
pytest .skip ("authentication support needed" )
0 commit comments