diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cfed00f5..6fbcdea7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - Speed up MatrixExpr.add.reduce via quicksum - Speed up np.ndarray(..., dtype=np.float64) @ MatrixExpr - MatrixExpr and MatrixExprCons use `__array_ufunc__` protocol to control all numpy.ufunc inputs and outputs +- Set `__array_priority__` for MatrixExpr and MatrixExprCons ### Removed ## 6.0.0 - 2025.xx.yy diff --git a/src/pyscipopt/matrix.pxi b/src/pyscipopt/matrix.pxi index 36e0006be..d1d4ad793 100644 --- a/src/pyscipopt/matrix.pxi +++ b/src/pyscipopt/matrix.pxi @@ -16,6 +16,8 @@ cnp.import_array() class MatrixExpr(np.ndarray): + __array_priority__ = 100 + def __array_ufunc__( self, ufunc: np.ufunc, @@ -82,6 +84,8 @@ class MatrixGenExpr(MatrixExpr): class MatrixExprCons(np.ndarray): + __array_priority__ = 101 + def __array_ufunc__(self, ufunc, method, *args, **kwargs): if method == "__call__": args = tuple(_ensure_array(arg) for arg in args)