Skip to content

Remove pn_dir from modern readers - #853

Merged
tompollard merged 2 commits into
mainfrom
modern/remove-pn-dir
Dec 2, 2026
Merged

tompollard merged 2 commits into
mainfrom
modern/remove-pn-dir

Conversation

@tompollard

Copy link
Copy Markdown
Member

Summary

Remove pn_dir from the modern readers: read_header, read_multi_segment_headers, read_record, read_signals, and read_annotations. They now require a complete local path, physionet:// URI, or HTTP URL. Legacy readers retain pn_dir and its migration warning.

This deliberately changes recently released signatures while the modern API is still being refined. The migration guide and changelog explain the replacement, including custom HTTP index servers. Tests cover rejection of pn_dir by modern readers and the existing legacy warnings.

Part of #852.

Verification

  • Offline suite: 1,684 passed, 4 skipped (bxb unavailable), 23 network tests deselected
  • Ruff check and format check: passed
  • Sphinx HTML build with warnings as errors: passed

@tompollard tompollard left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This does what #852 proposed for pn_dir. I'd merge it after a docs touch-up.

What I checked

  • On PhysioNet, read_record("physionet://mitdb/1.0.0/100"), read_annotations(..., annotator="atr") and read_header(...) return the same values, names, samples and symbols as the pn_dir="mitdb/1.0.0" legacy calls. The migration table covers custom index servers with a complete HTTP URL.
  • read_header, read_multi_segment_headers, read_record, read_signals and read_annotations no longer accept pn_dir. The legacy readers still accept it with the FutureWarning. Dropping _check_archive_read_args from the segment path is safe, since its only check was pn_dir.
  • The offline suite (1,684 passed, 4 skipped), the network tests (23 passed), Ruff, the strict docs build and CI all pass.

Docs that still describe pn_dir as accepted everywhere

A few passages read as if any reader still takes pn_dir, which is no longer true for the newer ones:

  • docs/io.rst around line 843: "A remote read needs a URI or the legacy pn_dir argument. Passing both a URI and pn_dir raises ValueError."
  • docs/io.rst around line 1003: the note calling pn_dir "a deprecated way to locate PhysioNet records".
  • README.md line 104: "The older pn_dir argument still works but is deprecated."

Saying "with the legacy readers (rdrecord, rdann, ...)" in each place would match the migration guide.

Related, possibly for #852 rather than this PR

iter_dataframes still takes pn_dir, and wraps it with warn_deprecated_pn_dir. It was added in 5.10.0, but its signature uses the legacy names throughout (record_name, sampfrom, sampto, physical, return_res, ignore_skew). The docs list it with the legacy functions, but it's the only chunked reader, so users of the newer API have no alternative. It's worth deciding whether it gets a modern signature (path, start, stop, kind, resolution, signal_alignment, no pn_dir) or a modern replacement.

Merge order

This and #854 conflict in read_signals (adjacent signature, docstring and call lines) and in tests/test_read_record.py. Both conflicts are small and mechanical. Whichever merges second needs a rebase.

@tompollard

Copy link
Copy Markdown
Member Author

I updated docs/io.rst and the README to say exactly which readers still accept pn_dir. The newer readers require a complete path or URI; legacy readers retain pn_dir and its warning. The warning-strict docs build passes.

I agree that chunked reading needs a modern entry point. I filed #856 for the signature and layout decision, keeping it separate from this pn_dir change. I will rebase #854 onto main after #851 and #853 are merged.

@tompollard tompollard left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks, c977c8e fixes all three passages. docs/io.rst and the README now say that pn_dir works only with the legacy readers and that the newer readers need a complete path or URI. Tracking the chunked reader separately in #856 makes sense.

The offline suite (1,684 passed, 4 skipped), Ruff and the strict docs build pass locally. CI is green, so this is ready to merge.

@tompollard
tompollard merged commit af37040 into main Dec 2, 2026
19 checks passed
@tompollard
tompollard deleted the modern/remove-pn-dir branch December 2, 2026 15:40
tompollard added a commit that referenced this pull request Dec 2, 2026
## Summary

Use `signal_alignment="aligned" | "raw"` on `read_record` and
`read_signals` in place of `ignore_skew`. The default remains aligned;
`"raw"` retains the stored skew, equivalent to the old
`ignore_skew=True`. Legacy `rdrecord` keeps its existing parameter.

This deliberately changes the recently released modern reader signatures
so reads and writes use the same words. The migration guide, API docs,
and changelog explain the change. The migration guide also notes that
newer signatures are still being refined before the next major release.

Tests compare aligned and raw results with the legacy reader, reject
invalid values and the removed modern keyword, and update the skew write
tests to use the new read option.

Part of #852. Rebases on `main` after #851 and #853.

## Verification

- Offline suite: 1,715 passed, 4 skipped (`bxb` unavailable), 23 network
tests deselected
- Ruff check and format check: passed
- Sphinx HTML build with warnings as errors: 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.

1 participant