Python 3.10–3.13 compatibility fixes + cross-version feature-equivalence test suite#952
Open
zhurong2020 wants to merge 2 commits into
Open
Python 3.10–3.13 compatibility fixes + cross-version feature-equivalence test suite#952zhurong2020 wants to merge 2 commits into
zhurong2020 wants to merge 2 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR makes the current
masterreleasable 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:
fix/python312-compatibility) carries the remaining compatibility fixes on top of the already-merged scikit-build-core + NumPy 2 build migration:ruamel.yaml(used by the CLI but previously undeclared)scipy.ndimage.interpolationimport →scipy.ndimagesph_harm/sph_harm_ywrapper for SciPy ≥ 1.15requires-pythonto>=3.10(NumPy 2.1 floor)[lbp3d]optional extra (scipy/trimesh)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).
masterhas since been modernized toscikit-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:
_cmatrices/_cshapeC kernel + the pure-NumPy first-order path.brain1case (viagetTestCase, skipped gracefully if offline).1e-6.Result
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
python tests/version_equivalence/generate_baseline.py. To verify any build:pytest tests/version_equivalence -v.