Skip to content

Import wfdb lazily: import braindecode.datasets no longer fails under -W error::DeprecationWarning with pandas 3.1 - #1524

Merged
bruAristimunha merged 1 commit into
braindecode:masterfrom
bruAristimunha:bd2deep/lazy-wfdb
Nov 2, 2026
Merged

bruAristimunha merged 1 commit into
braindecode:masterfrom
bruAristimunha:bd2deep/lazy-wfdb

Conversation

@bruAristimunha

Copy link
Copy Markdown
Collaborator

import braindecode.datasets imported wfdb at module level, although only SleepPhysionetChallenge2018._load_raw uses it. With pandas 3.1, wfdb's own import emits a Pandas4Warning (a DeprecationWarning), so

python -W error::DeprecationWarning -c "import braindecode, braindecode.models, braindecode.datasets, braindecode.preprocessing"

failed on an up-to-date stack (found by the 2.0 release audit, installed wheel, Python 3.14 / pandas 3.1).

  • wfdb is imported inside _load_raw.
  • New test test_import_datasets_does_not_load_wfdb (fresh interpreter, like the other lazy-import tests).
  • whats_new entry under Bug fixes.

Verified in a Voyager Job: pre-commit run --files on the changed files exits 0; test_lazy_imports.py, test_dependencies.py, test_sleep_physionet.py: 10 passed, 5 skipped.

Copilot AI balanced review requested due to automatic review settings November 2, 2026 16:52
bruAristimunha added a commit to bruAristimunha/braindecode that referenced this pull request Nov 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The changelog still contains an XXXX placeholder that produces an incorrect GitHub link instead of linking to the relevant PR.

1 open issue
What changed in this PR

This PR defers importing wfdb until a PhysioNet Challenge 2018 recording is loaded, preventing its pandas-related deprecation warning from breaking dataset imports when warnings are treated as errors.

Changes:

  • Move the wfdb import into _load_raw.
  • Add a fresh-interpreter regression test verifying dataset imports do not load wfdb.
  • Document the fix in the changelog.
File Description
test/​unit_tests/​test_lazy_imports.py Add regression coverage for lazy wfdb loading.
docs/​whats_new.rst Describe the import-related bug fix.
braindecode/​datasets/​sleep_physio_challe_18.py Import wfdb only when loading recordings.

Review effort: Balanced

Comment thread docs/whats_new.rst Resolved
Copilot AI balanced review requested due to automatic review settings November 2, 2026 16:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues require resolution before approval.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

import braindecode.datasets imported wfdb at module level, although only
SleepPhysionetChallenge2018._load_raw uses it. With pandas 3.1 wfdb's import
emits a DeprecationWarning (Pandas4Warning), so
python -W error::DeprecationWarning -c 'import braindecode.datasets' failed.
@codecov

codecov Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 91.34%. Comparing base (535e058) to head (fc551d0).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1524      +/-   ##
==========================================
- Coverage   91.34%   91.34%   -0.01%     
==========================================
  Files         170      170              
  Lines       22105    22105              
==========================================
- Hits        20192    20191       -1     
- Misses       1913     1914       +1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the change deferring wfdb imports until a recording is loaded.

No open issues 🎉

Review effort: Balanced

@bruAristimunha
bruAristimunha merged commit f24f220 into braindecode:master Nov 2, 2026
8 checks passed
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