Repository navigation
Add a guide for migrating from the legacy API - #829
Merged
Merged
Conversation
The new docs page maps the legacy function, argument and attribute names to the newer ones, shows how to replace pn_dir with physionet:// and HTTP paths, and lists the behaviour differences that matter when switching.
Member
Author
|
I found two accuracy issues in the migration guide that I'd fix before merging:
One smaller point: the opening examples read annotations but write only the signal record. Please either write the annotation in both examples or say that the copy contains signals only. The guide is useful overall. The docs check passes; these are wording and migration-behavior corrections. |
tompollard
marked this pull request as ready for review
December 1, 2026 06:10
Annotation.wrann does not store the sampling frequency by default, while the newer annotation writers do. MultiRecord has the source properties and segment_views but no metadata. Both examples now also write the annotations.
Member
Author
|
Thanks, all three were right. Fixed in d986164:
The strict docs build passes. |
tompollard
added a commit
that referenced
this pull request
Dec 1, 2026
## Summary Start deprecating the legacy function names from #672. Calling one of these now emits a `DeprecationWarning` that names its replacement: | Legacy | Use instead | |---|---| | `rdrecord`, `rdsamp`, `rdann` | `read_record`, `read_signals`, `read_annotations` | | `Record.wrsamp` | `Record.write` | | `Annotation.wrann` | `Annotation.write` | | `dl_database`, `get_record_list`, `get_dbs` | `download_records`, `list_records`, `list_databases` | | `show_ann_labels`, `show_ann_classes` | `show_annotation_labels`, `show_annotation_classes` | | `processing.Comparitor` | `processing.Comparator` | - **`DeprecationWarning`, not `FutureWarning`:** Python shows it in scripts, notebooks and test suites, but not by default when the call comes from another installed package, so users of downstream libraries aren't flooded. A later release can switch to `FutureWarning` before removal in a major version. - **Internal calls stay silent:** the newer functions, `mrgann`, the processing helpers and plotting still use some legacy implementations internally without warning. - **Left silent for now:** names whose replacement doesn't cover every use: `rdheader` (no replacement for `rd_segments=True`), the module-level `wrsamp` and `wrann` (which take arrays directly), `mrgann` and `MultiRecord.wrsamp`; `dl_files` (covered by `physionet.download`); and the legacy attribute and argument names. - **Works alongside the `pn_dir` warning:** the helpers now live in `wfdb.io._deprecation` and are shared with the `pn_dir` decorator. With two stacked wrappers, each one finds the real caller, so `rdrecord("100", pn_dir=...)` emits both a `DeprecationWarning` and a `FutureWarning`, each pointing at the user's line. Python 3.11 is still supported, so this doesn't rely on `skip_file_prefixes`. - **`show_ann_labels` and `show_ann_classes`** become thin wrappers instead of identical aliases. **`Comparitor`** resolves through a module `__getattr__` in `wfdb.processing` and `wfdb.processing.evaluate`, so old pickles still load (with a warning). `__all__` keeps `Comparitor` in star imports of both modules, which warn at the import. - **Docs and tests:** the migration guide and changelog are updated. Because many existing tests exercise the legacy names on purpose, pytest ignores this specific warning message; the new `tests/test_legacy_deprecations.py` checks the warnings explicitly. The warning messages refer to the migration guide added in #829. ## Checks - New tests: each legacy name warns exactly once at the caller's line; the newer API and internal legacy calls are silent with `DeprecationWarning` as an error; old `Comparitor` pickles load. - Checked by hand: a script calling `rdrecord` shows the warning at its own line, while the same call from an imported library module stays silent under default filters. `import wfdb` is clean with `-W error::DeprecationWarning`. - Offline suite: 1,587 passed, 4 skipped. Ruff check and format, and the Sphinx build with warnings as errors: passed. <sub>@tompollard 🟥 red 🦥 sloth · aspen</sub>
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
Add a "Migrating from the legacy API" page to the docs, linked under Other Content. It gathers the old → new mappings that are currently spread through
docs/io.rst, the processing docs and the changelog:Recordattributes,Annotationattributes and processing arguments;pn_dirwithphysionet://paths or complete HTTP URLs;merge_annotations's exclusivestop, andread_annotationsrejecting record files.It notes that older names keep working without warnings, apart from
pn_dir, and thatdl_fileshas no newer name becausephysionet.downloadcovers whole-project downloads.Related to #672.
Checks
main.pn_dirFutureWarnings, and the newer one emits none.@tompollard 🟥 red 🦥 sloth · aspen