Skip to content

Commit abd94f9

Browse files
committed
Try original codes
1 parent 06f8ebc commit abd94f9

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/pyscipopt/matrix.pxi

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,28 @@ class MatrixGenExpr(MatrixExpr):
9797
class MatrixExprCons(np.ndarray):
9898

9999
def __le__(self, other: Union[float, int, Expr, np.ndarray, MatrixExpr]) -> MatrixExprCons:
100-
return _matrixexpr_richcmp(self, other, 1)
100+
expr_cons_matrix = np.empty(self.shape, dtype=object)
101+
if _is_number(other) or isinstance(other, Expr):
102+
for idx in np.ndindex(self.shape):
103+
expr_cons_matrix[idx] = self[idx] <= other
104+
elif isinstance(other, np.ndarray):
105+
for idx in np.ndindex(self.shape):
106+
expr_cons_matrix[idx] = self[idx] <= other[idx]
107+
else:
108+
raise TypeError(f"Unsupported type {type(other)}")
109+
110+
return expr_cons_matrix.view(MatrixExprCons)
101111

102112
def __ge__(self, other: Union[float, int, Expr, np.ndarray, MatrixExpr]) -> MatrixExprCons:
103-
return _matrixexpr_richcmp(self, other, 5)
113+
expr_cons_matrix = np.empty(self.shape, dtype=object)
114+
if _is_number(other) or isinstance(other, Expr):
115+
for idx in np.ndindex(self.shape):
116+
expr_cons_matrix[idx] = self[idx] >= other
117+
elif isinstance(other, np.ndarray):
118+
for idx in np.ndindex(self.shape):
119+
expr_cons_matrix[idx] = self[idx] >= other[idx]
120+
else:
121+
raise TypeError(f"Unsupported type {type(other)}")
104122

105123
def __eq__(self, other):
106124
raise NotImplementedError("Cannot compare MatrixExprCons with '=='.")

0 commit comments

Comments
 (0)