CVXPY
The CVXPY pack has 5 rules, and xpd can fix 1 of them.
The CVXPY pack checks problem construction, solve results, and expression syntax. The examples were verified with CVXPY 1.9.3.
Problems and solver results
Section titled “Problems and solver results”| Rule | Severity | Fix | What it finds |
|---|---|---|---|
| mutate-problem-constraints | error | none | CVXPY's Problem.constraints returns a shallow copy of the list. |
| solve-result-as-status | warning | none | CVXPY's Problem.solve() returns the objective value. |
Expression construction
Section titled “Expression construction”| Rule | Severity | Fix | What it finds |
|---|---|---|---|
| implicit-reshape-order | warning | safe | CVXPY 1.x uses column-major order when reshape, vec, or Expression.flatten receives no order or receives None. |
| star-matmul | warning | none | CVXPY interprets * between non-scalar expressions as matrix multiplication. |
| dense-identity-quad-form | info | none | CVXPY's quad_form(x, np.eye(n)) allocates a dense square identity matrix to express the sum of the squares of a real vector. |
Runtime evidence
Section titled “Runtime evidence”| Rule | Observed with CVXPY 1.9.3 | Fix |
|---|---|---|
| mutate-problem-constraints | The three list edits left zero constraints in the problem. A new problem with the added lower bound changed the minimum from 0 to 1. | None |
| solve-result-as-status | The optimal objective of 0 was false. The infeasible objective of infinity was true. | None |
| implicit-reshape-order | Omitted order and literal None emitted a FutureWarning and gave the same values as "F" for all three APIs. |
Safe |
| star-matmul | A 3 by 3 parameter times a length-3 variable gave the same length-3 result as @. The elementwise product was 3 by 3. |
None |
| dense-identity-quad-form | Both identity constructors gave a scalar of 14 for [1, 2, 3], as did sum_squares. |
None |
Rules use imports and local bindings to resolve CVXPY calls, including renamed imports. Shape checks use literal dimensions in direct calls and unambiguous assignments in the same block.