Skip to content

Commit ab6805b

Browse files
committed
Rename _to_matrix to _ensure_matrix
Rename helper function _to_matrix to _ensure_matrix and update its call site in ExprLike ufunc handling. The change preserves behavior (numpy arrays are viewed as MatrixExpr/MatrixGenExpr and other Expr instances map to MatrixExpr/MatrixGenExpr) while clarifying the function's intention.
1 parent 08c5088 commit ab6805b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/pyscipopt/expr.pxi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ cdef class ExprLike:
251251
return NotImplemented
252252
# If the np.ndarray is of numeric type, all arguments are converted to
253253
# MatrixExpr or MatrixGenExpr and then the ufunc is applied.
254-
return ufunc(*[_to_matrix(a) for a in args], **kwargs)
254+
return ufunc(*[_ensure_matrix(a) for a in args], **kwargs)
255255

256256
if ufunc is np.add:
257257
return args[0] + args[1]
@@ -1056,7 +1056,7 @@ cdef inline object _wrap_ufunc(object x, object ufunc):
10561056
return res.view(MatrixGenExpr) if isinstance(res, np.ndarray) else res
10571057
return ufunc(_to_const(x))
10581058

1059-
cdef inline object _to_matrix(object arg):
1059+
cdef inline object _ensure_matrix(object arg):
10601060
if type(arg) is np.ndarray:
10611061
return arg.view(MatrixExpr)
10621062
matrix = MatrixExpr if isinstance(arg, Expr) else MatrixGenExpr

0 commit comments

Comments
 (0)