Skip to content

Fix canonicalization and matrix solution recovery bugs#7

Merged
SteveDiamond merged 9 commits into
cvxpy:mainfrom
haozhu10015:main
May 23, 2026
Merged

Fix canonicalization and matrix solution recovery bugs#7
SteveDiamond merged 9 commits into
cvxpy:mainfrom
haozhu10015:main

Conversation

@haozhu10015
Copy link
Copy Markdown
Contributor

Summary

This PR fixes several uncovered bugs in expression canonicalization and solver solution recovery.

Changes

  • Fix sum_squares canonicalization outside native objective form so constraints model ||x||², not ||x||.
  • Fix quad_over_lin canonicalization to include the denominator in the SOC epigraph.
  • Fix power(x, 2) so it remains elementwise instead of collapsing vector inputs through sum_squares.
  • Add axis-aware canonicalization for sum_axis(..., 0) and sum_axis(..., 1).
  • Fix sum_axis shape inference for axis = 1.
  • Fix column-major element extraction for matrix-shaped affine expressions.
  • Preserve original variable shapes through stuffing and solution unpacking, so matrix variables are returned as matrices instead of flattened vectors.

Tests

  • Added tests/canon_tests.rs for canonicalization regressions; the previous sum_squares tests are merged here.
  • Added tests/solver_tests.rs for matrix solution recovery.
  • Added direct Expr::Sum(..., axis) shape unit coverage.

@SteveDiamond SteveDiamond merged commit 6fb7b3a into cvxpy:main May 23, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants