cvxpy/star-matmul
| Rule | star-matmul |
|---|---|
| Pack | CVXPY |
| Severity | warning |
| Fix | none, edit by hand |
| Library versions | CVXPY 1.1 and later |
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.
Message
Section titled “Message”xpd prints this message with the issue. A name that starts with $ stands for code from your file.
CVXPY uses * between these non-scalar expressions for matrix multiplication. Use @ for matrix multiplication or cvxpy.multiply for elementwise multiplication.Browse the other rules of the CVXPY pack.