@@ -54,7 +54,7 @@ def _expr_richcmp(self, other, op):
54
54
elif isinstance (other, MatrixExpr):
55
55
return _expr_richcmp(other, self , 5 )
56
56
else :
57
- raise NotImplementedError
57
+ raise TypeError (f " Unsupported type {type(other)} " )
58
58
elif op == 5 : # >=
59
59
if isinstance (other, Expr) or isinstance (other, GenExpr):
60
60
return (self - other) >= 0.0
@@ -63,7 +63,7 @@ def _expr_richcmp(self, other, op):
63
63
elif isinstance (other, MatrixExpr):
64
64
return _expr_richcmp(other, self , 1 )
65
65
else :
66
- raise NotImplementedError
66
+ raise TypeError (f " Unsupported type {type(other)} " )
67
67
elif op == 2 : # ==
68
68
if isinstance (other, Expr) or isinstance (other, GenExpr):
69
69
return (self - other) == 0.0
@@ -72,7 +72,7 @@ def _expr_richcmp(self, other, op):
72
72
elif isinstance (other, MatrixExpr):
73
73
return _expr_richcmp(other, self , 2 )
74
74
else :
75
- raise NotImplementedError
75
+ raise TypeError (f " Unsupported type {type(other)} " )
76
76
else :
77
77
raise NotImplementedError (" Can only support constraints with '<=', '>=', or '=='." )
78
78
@@ -181,7 +181,7 @@ cdef class Expr:
181
181
left,right = right,left
182
182
terms = left.terms.copy()
183
183
184
- if isinstance (right, Expr):
184
+ if isinstance (right, ( Expr, ExprCons) ):
185
185
# merge the terms by component-wise addition
186
186
for v,c in right.terms.items():
187
187
terms[v] = terms.get(v, 0.0 ) + c
0 commit comments