Skip to content

Commit 40a7efe

Browse files
committed
Set __array_priority__ for MatrixExpr and MatrixExprCons
Added __array_priority__ attributes to MatrixExpr and MatrixExprCons classes to ensure correct precedence in NumPy operations involving these custom ndarray subclasses.
1 parent a82bf15 commit 40a7efe

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/pyscipopt/matrix.pxi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ cnp.import_array()
1717

1818
class MatrixExpr(np.ndarray):
1919

20+
__array_priority__ = 100
21+
2022
def __array_ufunc__(
2123
self,
2224
ufunc: np.ufunc,
@@ -84,6 +86,8 @@ class MatrixGenExpr(MatrixExpr):
8486

8587
class MatrixExprCons(np.ndarray):
8688

89+
__array_priority__ = 101
90+
8791
def __array_ufunc__(self, ufunc, method, *args, **kwargs):
8892
if method == "__call__":
8993
args = tuple(_ensure_array(arg) for arg in args)

0 commit comments

Comments
 (0)