Skip to content

chore: drop EOL Python 3.10; relax pandas to >= 2.2.2; shim wfdb for pandas 3 - #93

Open
wenh06 wants to merge 5 commits into
masterfrom
chore/drop-py310
Open

wenh06 wants to merge 5 commits into
masterfrom
chore/drop-py310

Conversation

@wenh06

@wenh06 wenh06 commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

What

Three related changes, modernizing the Python/pandas support ahead of 0.0.34.

1. Python 3.10 dropped (EOL 2026-10)

  • requires-python >= 3.11, 3.10 classifier removed
  • CI matrix 3.11 / 3.12 / 3.13 / 3.14 / 3.15; nightly full-suite subset 3.11 / 3.12 / 3.14 / 3.15 (oldest / primary / newest-two principle kept)
  • install docs: "Python 3.11 – 3.15"

2. pandas upper bound removed (pandas >= 2.2.2)

Verified under python 3.13 / pandas 3.1.0 / wfdb 4.3.1:

  • torch_ecg's own code contains no pandas-3-sensitive patterns (no set_index(<str col>.values) anywhere)
  • the readers never pass summarize_labels=True to wfdb.rdann (default False), so no torch_ecg code path reaches the one crashing wfdb API; rdann itself was probed and works under pandas 3.1

Dropping 3.10 makes the floor clean: every supported Python can resolve pandas 3.x.

3. wfdb shim for the one reachable crash

wfdb <= 4.3.1's Annotation.get_contained_labels raises TypeError under pandas >= 3 (set_index on an ArrowStringArray). End users can reach it on the Annotation objects our readers return (public wfdb API, also invoked by rdann(..., summarize_labels=True)).

torch_ecg/databases/_wfdb_compat.py patches the method with the fix from MIT-LCP/wfdb-python#575 plus drop=False -- without it the returned contained_labels loses the symbol/description column versus the pandas<3 path; with it the output schema is verified identical to the pandas 2.3 reference ((1, 4): label_store/symbol/description/n_occurrences). The drop=False correction was also pushed to the upstream PR (9af7b67) with an explanatory comment.

The shim activates only when pandas >= 3 AND the installed wfdb still contains the buggy pattern (source-level check), so any upstream release carrying the fix disables it automatically -- no version-number guessing.

Tests

test/test_databases/test_wfdb_compat.py: patched path (symbol-carrying annotation, column survival, counts) + idempotency. 2 passed under Python 3.13 / pandas 3.1; output cross-checked against the pandas 2.3.3 / wfdb 4.2.0 reference run.

Committed with --no-verify (master does not carry the pre-commit Python 3.11 pin from #90 yet); pre-commit.ci will confirm.

…pandas 3

Three related changes modernizing the Python/pandas support:

- Python 3.10 (EOL 2026-10) is dropped: requires-python >= 3.11, the
  3.10 classifier removed, CI matrix 3.11-3.15, nightly full-suite
  subset 3.11/3.12/3.14/3.15, install docs updated.
- The pandas upper bound becomes a floor: pandas >= 2.2.2.  Verified
  under python 3.13 / pandas 3.1.0 / wfdb 4.3.1: torch_ecg's own code
  has no pandas-3-sensitive patterns and its readers never pass
  summarize_labels=True to wfdb.rdann, so no torch_ecg code path
  reaches the one crashing wfdb API.
- That API is still reachable by end users on the Annotation objects
  our readers return, so a guarded shim
  (torch_ecg/databases/_wfdb_compat.py, applied from databases/base.py)
  patches Annotation.get_contained_labels with the fix from
  MIT-LCP/wfdb-python#575 plus drop=False (without it the returned
  contained_labels loses the symbol/description column versus the
  pandas<3 path -- output schema now verified identical: (1, 4),
  label_store/symbol/description/n_occurrences).  The shim activates
  only when pandas >= 3 AND the installed wfdb still contains the
  buggy pattern (source-level check), so any upstream release carrying
  the fix disables it automatically.

New test test_databases/test_wfdb_compat.py covers the patched path
and idempotency; validated on pandas 3.1 (patched path) and the
pandas 2 reference behavior.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-01T07:02:38.097164Z
We couldn’t complete this review. Comment @codex review to try again.
0436905 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

# the installed wfdb is already fixed (or restructured); nothing to do
return

def get_contained_labels(self, inplace: bool = True):
@codecov

codecov Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.77%. Comparing base (53c0998) to head (ff0f2ca).
⚠️ Report is 14 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
torch_ecg/databases/_wfdb_compat.py 94.82% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #93      +/-   ##
==========================================
- Coverage   93.47%   92.77%   -0.71%     
==========================================
  Files         138      139       +1     
  Lines       18628    18688      +60     
==========================================
- Hits        17412    17337      -75     
- Misses       1216     1351     +135     
Flag Coverage Δ
core 67.40% <95.00%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
torch_ecg/databases/base.py 80.39% <100.00%> (-7.22%) ⬇️
torch_ecg/databases/_wfdb_compat.py 94.82% <94.82%> (ø)

... and 1 file with indirect coverage changes

wenh06 and others added 3 commits November 1, 2026 15:10
…db shim

Second review note on MIT-LCP/wfdb-python#575 (cbrnr): pandas 3.1
deprecates the inplace keyword of DataFrame.set_index (Pandas4Warning,
removed in pandas 4) -- the shim would have broken on pandas 4.
Convert all four set_index calls in the patched method to the
reassignment form; the shim now emits no deprecation warnings of its
own (the one remaining Pandas4Warning in a get_contained_labels call
chain comes from wfdb's own set_label_elements, outside this shim's
method).  Output schema and values re-verified identical to the
pandas 2.3 reference.
Codecov reported 20 uncovered lines in _wfdb_compat.py (patch coverage
64.91%) and the code-quality review flagged two nits:

- tests now exercise every branch of the patched
  get_contained_labels: label_store, description, custom labels as
  triplets and as a DataFrame (label_store 1-49 per wfdb validation),
  the no-labels exception, and the inplace=True path (previously only
  the symbol branch and inplace=False were covered)
- apply_wfdb_pandas3_compat now ends with an explicit return instead
  of mixing bare guard returns with an implicit fall-through
- drop the unused _CWD module global from the test file

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant