@@ -326,26 +326,26 @@ cdef class ExprCons:
326
326
def __richcmp__ (self , other , op ):
327
327
''' turn it into a constraint'''
328
328
if op == 1 : # <=
329
- if not self ._rhs is None :
330
- raise TypeError (' ExprCons already has upper bound' )
331
- assert not self ._lhs is None
329
+ if not self ._rhs is None :
330
+ raise TypeError (' ExprCons already has upper bound' )
331
+ assert not self ._lhs is None
332
332
333
- if not _is_number(other):
334
- raise TypeError (' Ranged ExprCons is not well defined!' )
333
+ if not _is_number(other):
334
+ raise TypeError (' Ranged ExprCons is not well defined!' )
335
335
336
- return ExprCons(self .expr, lhs = self ._lhs, rhs = float (other))
336
+ return ExprCons(self .expr, lhs = self ._lhs, rhs = float (other))
337
337
elif op == 5 : # >=
338
- if not self ._lhs is None :
339
- raise TypeError (' ExprCons already has lower bound' )
340
- assert self ._lhs is None
341
- assert not self ._rhs is None
338
+ if not self ._lhs is None :
339
+ raise TypeError (' ExprCons already has lower bound' )
340
+ assert self ._lhs is None
341
+ assert not self ._rhs is None
342
342
343
- if not _is_number(other):
344
- raise TypeError (' Ranged ExprCons is not well defined!' )
343
+ if not _is_number(other):
344
+ raise TypeError (' Ranged ExprCons is not well defined!' )
345
345
346
- return ExprCons(self .expr, lhs = float (other), rhs = self ._rhs)
346
+ return ExprCons(self .expr, lhs = float (other), rhs = self ._rhs)
347
347
else :
348
- raise TypeError
348
+ raise NotImplementedError ( " Ranged ExprCons can only support with '<=' or '>='. " )
349
349
350
350
def __repr__ (self ):
351
351
return ' ExprCons(%s , %s , %s )' % (self .expr, self ._lhs, self ._rhs)
0 commit comments