Skip to content

Comments

PR review medium effort fixes: deduplicate canonicalizers and optimiz…#144

Merged
Transurgeon merged 1 commit intocvxpy-mergefrom
pr-review-medium-fixes
Feb 3, 2026
Merged

PR review medium effort fixes: deduplicate canonicalizers and optimiz…#144
Transurgeon merged 1 commit intocvxpy-mergefrom
pr-review-medium-fixes

Conversation

@Transurgeon
Copy link
Member

…e bounds

  • Add _common.py with canonicalize_unary_smooth() helper to reduce code duplication across hyperbolic, trig, exp, and prod canonicalizers
  • Refactor canonicalizer files to use the common helper
  • Preallocate numpy arrays in Bounds class instead of list extend + convert
  • Fix hessian() to return typed empty array (dtype=np.float64)
  • Cache empty hessian structure in hessianstructure() for quasi-Newton

Description

Please include a short summary of the change.
Issue link (if applicable):

Type of change

  • New feature (backwards compatible)
  • New feature (breaking API changes)
  • Bug fix
  • Other (Documentation, CI, ...)

Contribution checklist

  • Add our license to new files.
  • Check that your code adheres to our coding style.
  • Write unittests.
  • Run the unittests and check that they’re passing.
  • Run the benchmarks to make sure your change doesn’t introduce a regression.

…e bounds

- Add _common.py with canonicalize_unary_smooth() helper to reduce code
  duplication across hyperbolic, trig, exp, and prod canonicalizers
- Refactor canonicalizer files to use the common helper
- Preallocate numpy arrays in Bounds class instead of list extend + convert
- Fix hessian() to return typed empty array (dtype=np.float64)
- Cache empty hessian structure in hessianstructure() for quasi-Newton

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@Transurgeon Transurgeon merged commit a87c4f1 into cvxpy-merge Feb 3, 2026
19 of 20 checks passed
@github-actions
Copy link

github-actions bot commented Feb 3, 2026

Benchmarks that have stayed the same:

   before           after         ratio
 [a87c4f1f]       [20f9f050]
      333±0ms          355±0ms     1.07  gini_portfolio.Murray.time_compile_problem
      509±0ms          530±0ms     1.04  semidefinite_programming.SemidefiniteProgramming.time_compile_problem
      5.29±0s          5.45±0s     1.03  optimal_advertising.OptimalAdvertising.time_compile_problem
      2.13±0s          2.18±0s     1.02  quantum_hilbert_matrix.QuantumHilbertMatrix.time_compile_problem
      910±0ms          931±0ms     1.02  gini_portfolio.Cajas.time_compile_problem
      418±0ms          428±0ms     1.02  gini_portfolio.Yitzhaki.time_compile_problem
     14.1±0ms         14.4±0ms     1.02  simple_LP_benchmarks.SimpleFullyParametrizedLPBenchmark.time_compile_problem
     34.5±0ms         35.2±0ms     1.02  matrix_stuffing.SmallMatrixStuffing.time_compile_problem
      35.0±0s          35.5±0s     1.01  sdp_segfault_1132_benchmark.SDPSegfault1132Benchmark.time_compile_problem
      16.4±0s          16.6±0s     1.01  simple_LP_benchmarks.SimpleLPBenchmark.time_compile_problem
      1.33±0s          1.34±0s     1.01  matrix_stuffing.ParamConeMatrixStuffing.time_compile_problem
      1.18±0s          1.19±0s     1.01  simple_LP_benchmarks.SimpleScalarParametrizedLPBenchmark.time_compile_problem
      1.74±0s          1.75±0s     1.01  finance.FactorCovarianceModel.time_compile_problem
      783±0ms          787±0ms     1.01  matrix_stuffing.ConeMatrixStuffingBench.time_compile_problem
      216±0ms          217±0ms     1.00  high_dim_convex_plasticity.ConvexPlasticity.time_compile_problem
      272±0ms          273±0ms     1.00  matrix_stuffing.ParamSmallMatrixStuffing.time_compile_problem
      6.55±0s          6.56±0s     1.00  huber_regression.HuberRegression.time_compile_problem
     13.8±0ms         13.9±0ms     1.00  simple_QP_benchmarks.ParametrizedQPBenchmark.time_compile_problem
      21.2±0s          21.2±0s     1.00  finance.CVaRBenchmark.time_compile_problem
      1.32±0s          1.32±0s     0.99  simple_QP_benchmarks.LeastSquares.time_compile_problem
      289±0ms          286±0ms     0.99  simple_QP_benchmarks.SimpleQPBenchmark.time_compile_problem
      3.35±0s          3.32±0s     0.99  simple_QP_benchmarks.UnconstrainedQP.time_compile_problem
      7.84±0s          7.75±0s     0.99  svm_l1_regularization.SVMWithL1Regularization.time_compile_problem
      1.91±0s          1.87±0s     0.98  tv_inpainting.TvInpainting.time_compile_problem
      406±0ms          395±0ms     0.97  slow_pruning_1668_benchmark.SlowPruningBenchmark.time_compile_problem

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.

1 participant