Skip to content

Honor iterations in SciPy LinearLUSolver instead of capping at 10#1210

Open
gaoflow wants to merge 1 commit into
usnistgov:masterfrom
gaoflow:fix-1208-scipy-lu-iterations
Open

Honor iterations in SciPy LinearLUSolver instead of capping at 10#1210
gaoflow wants to merge 1 commit into
usnistgov:masterfrom
gaoflow:fix-1208-scipy-lu-iterations

Conversation

@gaoflow

@gaoflow gaoflow commented Jun 4, 2026

Copy link
Copy Markdown

Fixes #1208.

Problem

The SciPy LinearLUSolver runs its iterative-refinement loop over range(min(self.iterations, 10)) (linearLUSolver.py:68), 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 was inconsistent and ignored iterations set 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 iterations to whatever they want.

Fix

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 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 in fipy/solvers/test.py (mirroring the backend-conditional registration in fipy/matrices/test.py). With an unreachable tolerance=0. the loop runs the full requested count, so iterations=12 records 12 refinement sweeps — it recorded 10 before this change.

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.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

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
* Add policy on AI contributions

Inspired by #1179, #1200, #1201, #1202, #1203, #1205, #1206, #1209, #1210

* Ignore extractive issues and PRs in changelog

https://llvm.org/docs/AIToolPolicy.html#extractive-contributions
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.

SciPy LinearLUSolver has artificial limit of 10 iterations

1 participant