From beb0a4fee9686a6519f328b6ceac57d3fec50fc9 Mon Sep 17 00:00:00 2001 From: ocayon Date: Thu, 8 Oct 2026 14:49:51 +0200 Subject: [PATCH] fix(solver): restore the reject condition broken by 1105122 (SyntaxError) 1105122 (Copilot Autofix, "Refactor ratio and gate condition") replaced five lines with one: it kept the new ratio expression but deleted the crossed_gate assignment and the opening `if not finite(trial) or (` with its condition, leaving a bare `):` at Solver.py:1447. Every `import VSM` on main raised SyntaxError: unmatched ')', so every fresh install of a package that depends on VSM@main (AWETrim) failed. Restores the condition and keeps the autofix's intended change: a trial with exactly zero residual now has ratio = inf (accepted) instead of 0 (rejected). --- src/VSM/core/Solver.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/VSM/core/Solver.py b/src/VSM/core/Solver.py index 8b7457e..576f3ba 100644 --- a/src/VSM/core/Solver.py +++ b/src/VSM/core/Solver.py @@ -1444,6 +1444,10 @@ def finite(state): trial = evaluate(current["x"] + direction) evaluations += 1 ratio = np.inf if finite(trial) and norm(trial) == 0 else (norm(current) / norm(trial) if finite(trial) else 0.0) + crossed_gate = finite(trial) and trial["gate"] != current["gate"] + if not finite(trial) or ( + ratio < self._newton_reject_ratio + and not (crossed_gate and dt <= dt_restart) ): # Residual grew too much: reject and shrink. EXCEPT across # the viscosity gate, the residual's one discontinuity: