File tree Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -1419,6 +1419,9 @@ cdef class Boolean(Expr):
1419
1419
def logical_not (self ):
1420
1420
return c2py(< rcp_const_basic> (deref(symengine.rcp_static_cast_Boolean(self .thisptr)).logical_not()))
1421
1421
1422
+ def __bool__ (self ):
1423
+ raise TypeError (" cannot determine truth value of Boolean" )
1424
+
1422
1425
1423
1426
cdef class BooleanAtom(Boolean):
1424
1427
@@ -1524,6 +1527,10 @@ class Relational(Boolean):
1524
1527
def is_Relational (self ):
1525
1528
return True
1526
1529
1530
+ def __bool__ (self ):
1531
+ raise TypeError (" cannot determine truth value of Relational" )
1532
+
1533
+
1527
1534
Rel = Relational
1528
1535
1529
1536
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ def test_eval_double2():
16
16
x = Symbol ("x" )
17
17
e = sin (x )** 2 + sqrt (2 )
18
18
raises (RuntimeError , lambda : e .n (real = True ))
19
- assert abs (e .n () - x ** 2 - 1.414 ) < 1e-3
19
+ assert abs (e .n () - sin ( x ) ** 2.0 - 1.414 ) < 1e-3
20
20
21
21
def test_n ():
22
22
x = Symbol ("x" )
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ def test_And():
44
44
assert And (True , False ) == false
45
45
assert And (False , False ) == false
46
46
assert And (True , True , True ) == true
47
+ raises (TypeError , lambda : x < y and y < 1 )
47
48
48
49
49
50
def test_Or ():
@@ -54,6 +55,7 @@ def test_Or():
54
55
assert Or (True , False ) == true
55
56
assert Or (False , False ) == false
56
57
assert Or (True , False , False ) == true
58
+ raises (TypeError , lambda : x < y or y < 1 )
57
59
58
60
59
61
def test_Nor ():
@@ -116,4 +118,4 @@ def test_Contains():
116
118
assert Contains (x , Interval (1 , 1 )) != false
117
119
assert Contains (oo , Interval (- oo , oo )) == false
118
120
assert Contains (- oo , Interval (- oo , oo )) == false
119
-
121
+
You can’t perform that action at this time.
0 commit comments