From e0e1a0e736ecd0bdf4e4e25248145c3daedff019 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 15 Oct 2026 12:13:17 +0200 Subject: [PATCH] Add a deterministic minres test for the eps stopping criterion The istop = 3 branch of minres was reached only by test_minres_x0_exact_solution, where the initial residual is rounding noise of the same order as the eps threshold. Whether it was hit depended on the runner, so Coveralls flipped by one line (-0.003%) on PRs with no source change. The new test uses a singular A with a large x0 in its null space and a tiny b. All values are exact in fp64 and the eps test passes by a factor of 2**27, so the branch is always reached. --- dpnp/tests/test_scipy_sparse_linalg.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dpnp/tests/test_scipy_sparse_linalg.py b/dpnp/tests/test_scipy_sparse_linalg.py index 980e0a9b707..cd994ffe985 100644 --- a/dpnp/tests/test_scipy_sparse_linalg.py +++ b/dpnp/tests/test_scipy_sparse_linalg.py @@ -1303,6 +1303,17 @@ def test_minres_x0_exact_solution(self): _, info = minres(ia, ib, x0=x_true, rtol=1e-12) assert info == 0 + @pytest.mark.skipif(not has_support_aspect64(), reason="fp64 is required") + def test_minres_x0_null_space(self): + # Large x0 in null(A) with a tiny b: ||A||*||x||*eps >= ||r0|| + # by ~2**27, so the eps stopping test (istop=3) is always hit + ia = dpnp.array([[1.0, 0.0], [0.0, 0.0]]) + ib = dpnp.full(2, 2.0**-40) + x0 = dpnp.array([0.0, 2.0**40]) + x, info = minres(ia, ib, x0=x0) + assert info == 0 + assert_allclose(x.asnumpy(), [2.0**-40, 2.0**40]) + @pytest.mark.skipif(not has_support_aspect64(), reason="fp64 is required") def test_minres_errors(self): # Mirrors test_cg_errors / test_gmres_errors. minres does not