@@ -97,10 +97,28 @@ class MatrixGenExpr(MatrixExpr):
97
97
class MatrixExprCons (np.ndarray ):
98
98
99
99
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)
101
111
102
112
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)}" )
104
122
105
123
def __eq__ (self , other ):
106
124
raise NotImplementedError (" Cannot compare MatrixExprCons with '=='." )
0 commit comments