Skip to content

Scale the DLR round-trip tolerance in the axis test by its conditioning - #92

Merged
shinaoka merged 1 commit into
mainlinefrom
test/axis-tolerance-dlr
Oct 7, 2026
Merged

shinaoka merged 1 commit into
mainlinefrom
test/axis-tolerance-dlr

Conversation

@shinaoka

@shinaoka shinaoka commented Oct 7, 2026

Copy link
Copy Markdown
Member

Companion to SpM-lab/sparse-ir-rs#326.

test_axis_on_three_dimensional_input compares the same logical data with the
coefficient axis in two places. The transform applies the same linear map either
way, but the contraction geometry can differ, so the two results differ by their
rounding amplified by the transform's conditioning. The three sampling
transforms are well conditioned and keep the fixed 1e-12 bound; the DLR round
trip is not (cond(-S_l V_l(w_p)) is ~2.2e5 for the fixture here), and a library
built from sparse-ir-rs main misses that bound by 2% (absolute 3.24e-12
against atol 3.19e-12).

The tolerance is now derived from the fixture's own conditioning rather than
hard-coded:

amp = np.linalg.cond(-basis.s[:, None] * basis.v(obj.sampling_points))
atol = max(1e-12, amp * np.finfo(np.float64).eps) * np.abs(back_ref).max()

Test only: no runtime code changes, and nothing to release.

Verified:

  • pytest tests/test_boundary.py -k axis_on_three -> 8 passed, both against the
    published pylibsparseir 0.10.0 wheel and against a library built from
    sparse-ir-rs main (4 failed before).
  • Full suite -> 356 passed against both libraries.
  • check_libsparseir_version_consistency.py -> all checks passed.

The axis test compares the same logical data with the coefficient axis in two
places. The transform applies the same linear map either way, but the
contraction geometry differs, so the two results differ by one rounding unit
amplified by the transform's own condition number. The sampling transforms are
well conditioned and keep the fixed 1e-12 bound; the DLR round trip is not
(cond ~ 2.2e5 for the fixture here), and a library built from sparse-ir-rs main
misses that bound by 2%.

SpM-lab/sparse-ir-rs#326.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@shinaoka
shinaoka merged commit 923e01a into mainline Oct 7, 2026
9 checks passed
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.

1 participant