cvxpy/implicit-reshape-order
| Rule | implicit-reshape-order |
|---|---|
| Pack | CVXPY |
| Severity | warning |
| Fix | safe, with xpd check --fix |
| Library versions | CVXPY 1.6 and later |
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
Message
Section titled “Message”xpd prints this message with the issue. A name that starts with $ stands for code from your file.
Specify order for CVXPY reshape. Use order="F" for column-major order or order="C" for row-major order.Browse the other rules of the CVXPY pack.