Skip to content

Python 3.12 support + scipy 1.16 fix#462

Merged
ThomasMBury merged 2 commits intoThomasMBury:mainfrom
energyscholar:maintenance/python312-compat
Apr 3, 2026
Merged

Python 3.12 support + scipy 1.16 fix#462
ThomasMBury merged 2 commits intoThomasMBury:mainfrom
energyscholar:maintenance/python312-compat

Conversation

@energyscholar
Copy link
Copy Markdown
Contributor

Hey Thomas — a colleague wanted to use ewstools on Python 3.12 and hit the version cap, so I dug into the dependency chain to see what it would take.

Turns out it's straightforward with a conservative approach:

  • numpy 1.26+ supports 3.12 and keeps all deprecated APIs — capped at <2.0 to avoid breaking changes (entropyhub isn't compatible with numpy 2.x yet)
  • arch just needs >=6.2 for compiled 3.12 wheels
  • TF <2.16 has no 3.12 wheels, so TF tests are gated to 3.9-3.11 using pytest.importorskip — rest of the suite runs fine without TF
  • Also updated the GitHub Actions versions (v3→v4/v5), dropped Python 3.8 (EOL Oct 2024), and corrected the TF optional dependency from <=2.16 to <2.16 (2.16.0 ships Keras 3, which is a breaking change)

While testing, I also found that scipy 1.16+ breaks signal.welch() when passed a pandas Series directly (they refactored the internals to use ShortTimeFFT). One-line fix: wrap with np.asarray() before passing. That's the second commit.

Happy to adjust anything — let me know!

- Add Python 3.12 to CI matrix with TF gate (no 3.12 wheels for TF <2.16)
- Drop Python 3.8 (EOL Oct 2024), update Actions to v4/v5
- Update dependency floors for 3.12 wheel availability (numpy>=1.26, arch>=6.2)
- Separate TF-dependent tests with pytest marker
- Correct TF version constraint (<=2.16 -> <2.16, excludes Keras 3)

Prepared with assistance from Claude Opus 4.6.
scipy 1.16.0 rewrote signal.welch internals to use ShortTimeFFT, which
performs tuple indexing (x[..., i0:i1]) that fails on pandas Series.
Convert input to ndarray before passing to signal.welch. np.asarray is
idempotent for ndarray input and safe across all scipy versions.

Prepared with assistance from Claude Opus 4.6.
@ThomasMBury
Copy link
Copy Markdown
Owner

Hi Bruce,
Thanks very much for your contribution here. I'm finally getting around to this. I'm just going to run a few tests before merging.

@ThomasMBury ThomasMBury merged commit 2c0d23f into ThomasMBury:main Apr 3, 2026
4 checks passed
@ThomasMBury
Copy link
Copy Markdown
Owner

Just tested locally on Python 3.12 and everything looks good. I appreciate the clean and well-documented changes - thanks!

@energyscholar
Copy link
Copy Markdown
Contributor Author

energyscholar commented Apr 3, 2026 via email

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