Skip to content

Python 3.10–3.13 compatibility fixes + cross-version feature-equivalence test suite#952

Open
zhurong2020 wants to merge 2 commits into
AIM-Harvard:masterfrom
zhurong2020:py312-compat-equiv-tests
Open

Python 3.10–3.13 compatibility fixes + cross-version feature-equivalence test suite#952
zhurong2020 wants to merge 2 commits into
AIM-Harvard:masterfrom
zhurong2020:py312-compat-equiv-tests

Conversation

@zhurong2020

Copy link
Copy Markdown

Summary

This PR makes the current master releasable on modern Python (CPython 3.10–3.13 / NumPy 2) and adds the missing scientific-trust guarantee that the modernization does not silently shift IBSI feature values.

It is a jointly-authored PR:

  • @steubk's commit (fix/python312-compatibility) carries the remaining compatibility fixes on top of the already-merged scikit-build-core + NumPy 2 build migration:
    • declare ruamel.yaml (used by the CLI but previously undeclared)
    • fix deprecated scipy.ndimage.interpolation import → scipy.ndimage
    • sph_harm / sph_harm_y wrapper for SciPy ≥ 1.15
    • raise requires-python to >=3.10 (NumPy 2.1 floor)
    • add [lbp3d] optional extra (scipy / trimesh)
  • My commit adds tests/version_equivalence/, a cross-version feature-equivalence regression suite.

Why

The last PyPI release (3.1.0, 2023-05) no longer installs on Python 3.12+ (see #900 / #932 / #949). master has since been modernized to scikit-build-core + numpy>=2, but a release needs confidence that the NumPy 1→2 / new-build transition reproduces established feature values — exactly what's been missing.

What the test suite checks

A deliberately broad panel to exercise the whole NumPy-2 / new-build surface:

  • Image types: Original + LoG (σ=1.0) + Wavelet → C-extension filtering, SciPy LoG, PyWavelets paths.
  • Feature classes: all 7 (firstorder, glcm, glrlm, glszm, gldm, ngtdm, shape) → every _cmatrices / _cshape C kernel + the pure-NumPy first-order path.
  • Cases (both fully public / reproducible, no private data): a deterministic synthetic phantom (no download) and the canonical brain1 case (via getTestCase, skipped gracefully if offline).
  • = 944 features × 2 cases = 1888 comparisons, each checked against a frozen reference baseline (pyradiomics 3.0.1 / NumPy 1.26.4 / CPython 3.10) at relative tolerance 1e-6.

Result

baseline current build comparisons verdict
3.0.1 / NumPy 1.26.4 / py3.10 3.1.0+py312fix / NumPy 2.5.0 / py3.13 1888 ✅ all within rtol 1e-6

Typical cross-stack difference is ~1e-14 (NumPy 1↔2 float reassociation on reductions such as Skewness / Kurtosis / Variance / GLCM ClusterShade) — orders of magnitude inside tolerance, the large majority bit-identical.

Notes

  • "Allow edits by maintainers" is enabled.
  • The build-system / compat work is @steubk's; this PR adds the verification on top of it (co-authored, not fork-and-claim).
  • To regenerate the baseline under a reference env: python tests/version_equivalence/generate_baseline.py. To verify any build: pytest tests/version_equivalence -v.

steubk and others added 2 commits May 1, 2026 12:00
Adds tests/version_equivalence: a self-contained pytest suite that proves the
modernized build (scikit-build-core + NumPy 2 + CPython 3.10-3.13) reproduces
the established pyradiomics feature values of the last NumPy-1.x release.

A deliberately broad panel — Original + LoG + Wavelet image types x all 7
feature classes (firstorder, glcm, glrlm, glszm, gldm, ngtdm, shape) = 944
features — is extracted on two fully public, reproducible cases (a deterministic
synthetic phantom requiring no download, and the canonical brain1 case fetched
via getTestCase) and compared to a frozen reference baseline (pyradiomics 3.0.1,
NumPy 1.26.4, CPython 3.10) at relative tolerance 1e-6.

Verified: 1888 comparisons (944 x 2 cases) all within 1e-6 against the steubk
fix/python312-compatibility build (3.1.0+py312fix, NumPy 2.5.0, CPython 3.13);
typical cross-stack difference ~1e-14 (NumPy 1->2 float reassociation on
reductions such as Skewness/Kurtosis/Variance/GLCM ClusterShade).

The build-system modernization and SciPy-compat fixes are steubk's work; this
commit adds the feature-equivalence verification on top of it.

Co-authored-by: steubk <ste.morelli@gmail.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.

2 participants