Honor iterations in SciPy LinearLUSolver instead of capping at 10#1210
Open
gaoflow wants to merge 1 commit into
Open
Honor iterations in SciPy LinearLUSolver instead of capping at 10#1210gaoflow wants to merge 1 commit into
gaoflow wants to merge 1 commit into
Conversation
The SciPy LinearLUSolver ran its iterative-refinement loop over range(min(self.iterations, 10)), silently capping the user-requested iteration count at 10. The PETSc and Trilinos LinearLUSolver implementations both loop over range(self.iterations) with no such cap, so the SciPy backend ignored iterations set above 10. Drop the cap so the SciPy solver honors iterations like the other backends. The refinement loop still breaks as soon as the residual meets the tolerance, so well-conditioned systems are unaffected; only an explicit request for more (or fewer) sweeps is now respected. Adds a regression doctest, registered for the SciPy solver suite. Fixes usnistgov#1208.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
guyer
added a commit
that referenced
this pull request
Jun 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1208.
Problem
The SciPy
LinearLUSolverruns its iterative-refinement loop overrange(min(self.iterations, 10))(linearLUSolver.py:68), silently capping the user-requested iteration count at 10. The PETSc and TrilinosLinearLUSolverimplementations both loop overrange(self.iterations)with no such cap, so the SciPy backend was inconsistent and ignorediterationsset above 10.As discussed in the issue, LU refinement rarely needs more than a couple of sweeps, but users should still be able to set
iterationsto whatever they want.Fix
Drop the cap so the SciPy solver honors
iterationslike the other backends. The refinement loop stillbreaks as soon as the residual meets the tolerance, so well-conditioned systems converge in the same one-to-few sweeps as before; only an explicit request for more (or fewer) sweeps is now respected.Test
Adds a regression doctest to
LinearLUSolver, registered for the SciPy solver suite infipy/solvers/test.py(mirroring the backend-conditional registration infipy/matrices/test.py). With an unreachabletolerance=0.the loop runs the full requested count, soiterations=12records 12 refinement sweeps — it recorded 10 before this change.