Skip to content

Commit 2f1d21d

Browse files
committed
Return NotImplemented for unsupported expr RHS
Change _expr_richcmp to return NotImplemented for unsupported right-hand operand types instead of raising TypeError, and remove the explicit numpy.ndarray special-case. This allows Python to fall back to reflected comparison methods when the other operand can handle the comparison.
1 parent c385d5e commit 2f1d21d

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

src/pyscipopt/expr.pxi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,8 @@ if TYPE_CHECKING:
6060

6161

6262
def _expr_richcmp(self: Union[Expr, GenExpr], other, int op):
63-
if isinstance(other, np.ndarray):
64-
return NotImplemented
6563
if not isinstance(other, GENEXPR_OP_TYPES):
66-
raise TypeError(f"Unsupported type {type(other)}")
64+
return NotImplemented
6765

6866
if op == Py_LE:
6967
if isinstance(other, NUMBER_TYPES):

0 commit comments

Comments
 (0)