fix(solver): build weight vector after pre-passes to match free param count #35

Merged
forbes merged 1 commits from fix/weight-vector-after-prepass into main 2026-02-23 03:19:28 +00:00
Owner

Problem

The weight vector was built before substitution_pass and single_equation_pass, which can fix variables and reduce the free parameter count. This caused a shape mismatch in newton_solve when the Jacobian (built from the reduced free params) had fewer columns than the weight vector had entries:

ValueError: operands could not be broadcast together with shapes (55,27) (1,28)

The broadcast happens at newton.py:103:

J_scaled = J * w_inv_sqrt[np.newaxis, :]

Fix

Move build_weight_vector() after both pre-passes in both the solve and drag paths, so its length matches the actual free parameters used by the Jacobian.

## Problem The weight vector was built before `substitution_pass` and `single_equation_pass`, which can fix variables and reduce the free parameter count. This caused a shape mismatch in `newton_solve` when the Jacobian (built from the reduced free params) had fewer columns than the weight vector had entries: ``` ValueError: operands could not be broadcast together with shapes (55,27) (1,28) ``` The broadcast happens at `newton.py:103`: ```python J_scaled = J * w_inv_sqrt[np.newaxis, :] ``` ## Fix Move `build_weight_vector()` after both pre-passes in both the solve and drag paths, so its length matches the actual free parameters used by the Jacobian.
forbes added 1 commit 2026-02-23 03:06:34 +00:00
The weight vector was built before substitution_pass and
single_equation_pass, which can fix variables and reduce the free
parameter count. This caused a shape mismatch in newton_solve when
the Jacobian had fewer columns than the weight vector had entries:

  ValueError: operands could not be broadcast together with shapes
  (55,27) (1,28)

Move build_weight_vector() after both pre-passes so its length
matches the actual free parameters used by the Jacobian.
forbes merged commit e7e4266f3d into main 2026-02-23 03:19:28 +00:00
forbes deleted branch fix/weight-vector-after-prepass 2026-02-23 03:19:31 +00:00
Sign in to join this conversation.