cvxpy/star-matmul
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| CVXPY | warning | none, edit by hand | CVXPY 1.1+ |
CVXPY interprets * between non-scalar expressions as matrix
multiplication. This use of the operator has been deprecated since 1.1.
prediction = coefficients * weightsprediction = coefficients @ weightsWhat the rule reports
Section titled “What the rule reports”The rule checks pairs of CVXPY vectors and matrices with compatible
literal dimensions from a call or an unambiguous local assignment. It
reads shapes passed by position or as shape=. For matrix multiplication,
the last left dimension must equal the first right dimension. The rule
leaves scalar, singleton, incompatible, and unknown shapes alone.
How to fix it
Section titled “How to fix it”Use @ for a matrix product. For an elementwise product, use
cp.multiply(coefficients, weights) with broadcast-compatible shapes.
Diagnostic message
Section titled “Diagnostic message”CVXPY uses * between these non-scalar expressions for matrix multiplication. Use @ for matrix multiplication or cvxpy.multiply for elementwise multiplication.See all rules in the CVXPY pack.