cvxpy/implicit-reshape-order
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| CVXPY | warning | safe, with xpd check --fix |
CVXPY 1.6+ |
CVXPY 1.x uses column-major order when reshape, vec, or
Expression.flatten receives no order or receives None. From CVXPY 1.6
these calls emit a FutureWarning. NumPy defaults to row-major order.
vector = cp.vec(matrix)vector = cp.vec(matrix, order="F")What the rule reports
Section titled “What the rule reports”The rule checks CVXPY's reshape and vec functions and the reshape
and flatten methods of locally resolved variables, parameters, and
constants. It finds order=None in any keyword position and through
parentheses. Argument unpacking is outside the rule. The omitted-order fix
checks calls without comments between arguments so the edit can preserve
their layout.
How to fix it
Section titled “How to fix it”xpd check --fix writes explicit "F" to preserve the CVXPY 1.x order.
Write "C" if the model uses NumPy's row-major order. With
[[1, 2, 3], [4, 5, 6]], those orders give [1, 4, 2, 5, 3, 6] and
[1, 2, 3, 4, 5, 6], respectively.
CVXPY changelog on reshape order
Diagnostic message
Section titled “Diagnostic message”Specify order for CVXPY reshape. Use order="F" for column-major order or order="C" for row-major order.See all rules in the CVXPY pack.