Skip to content

Work with pylibsparseir 0.10 as well as 0.8.3–0.9 - #88

Merged
shinaoka merged 4 commits into
mainlinefrom
fix/backend-0.10-compat
Sep 27, 2026
Merged

shinaoka merged 4 commits into
mainlinefrom
fix/backend-0.10-compat

Conversation

@shinaoka

Copy link
Copy Markdown
Member

pylibsparseir 0.10.0 (SpM-lab/sparse-ir-rs v0.10.0) is on PyPI. Three of its
changes reach this wrapper, and all three are handled so that one sparse-ir
works against every supported backend from 0.8.3 up.

Handle ownership (sparse-ir-rs#282). kernel.py, sve.py and poly.py
finalizers called _lib.spir_*_release on handles that 0.10 owns itself; the
raw entry point now refuses them, and the exception surfaced from __del__ as
a flood of warnings. _util.release_handle calls close() when the handle has
one and falls back to the release function otherwise.

basis_get_default_matsus_ext arity (sparse-ir-rs#274). The function grew
a basis_size argument and now returns the points. augment.py inspects the
signature once — not the reported version, since development builds report an
older one — and calls whichever form is present.

Known backend defects (#265, #273). The oracle tests were strict xfails,
so they failed as XPASS against a backend that fixed them. They are now the
same two states the Julia suite uses: xfail while the error is far above
tolerance, assert once it is not.

pylibsparseir moves to >=0.8.3,<0.11.0 in pyproject.toml and
.conda/meta.yaml. filterwarnings turns PytestUnraisableExceptionWarning
into an error, so an exception in a finalizer fails the suite instead of being
reported as a warning — that is what hid #282.

Verified against pylibsparseir 0.9.1 from PyPI and against 0.10.0 built from
sparse-ir-rs main: 356 passed on both.

shinaoka and others added 4 commits September 26, 2026 11:33
pylibsparseir >= 0.10 returns handles that own their C object, and its raw
_lib.spir_*_release entry points refuse them (SpM-lab/sparse-ir-rs#282).
The finalizers of the kernels, SVEResult and the function sets passed those
handles to _lib, so every dropped object printed an unraisable TypeError.

Release through close() when the handle has one and through the raw entry
point otherwise: older releases, and handles created by direct _lib calls
in any release, are raw pointers. An unraisable exception now fails the
test suite, and a regression test drops each kind of handle.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
pylibsparseir >= 0.10 changed basis_get_default_matsus_ext from
(basis, positive_only, points) to (basis, basis_size, positive_only,
fence=False), returning the points (SpM-lab/sparse-ir-rs#274). The old
call passed the output buffer as positive_only.

Detect the new API from the signature, not the version, since development
builds may report an older version, and keep the direct C calls for older
releases.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The strict xfails of O2/O4 (sparse-ir-rs#265) and O6 (sparse-ir-rs#273)
fail as XPASS on backends with the fixes. As in SparseIR.jl, xfail only when
the result shows the defect (an error above 1e3 * tol for #265, exactly the
wmax**-2 scaled result for #273) and require the tolerance otherwise.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@shinaoka
shinaoka merged commit 24670da into mainline Sep 27, 2026
9 checks passed
@shinaoka shinaoka mentioned this pull request Sep 27, 2026
shinaoka added a commit that referenced this pull request Sep 27, 2026
The only change since 2.1.4 is #88, which makes the wrapper work against
pylibsparseir 0.10 as well as 0.8.3–0.9. No public API changed.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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