Skip to content

Accept pathlib.Path record names in rdann - #626

Open
tompollard wants to merge 1 commit into
mainfrom
tp/rdann-pathlike
Open

tompollard wants to merge 1 commit into
mainfrom
tp/rdann-pathlike

Conversation

@tompollard

Copy link
Copy Markdown
Member

rdann fails when record_name is a pathlib.Path:

wfdb.rdann(pathlib.Path("sample-data/100"), "atr")
# TypeError: unsupported operand type(s) for +: 'PosixPath' and 'str'

The file name is built with record_name + "." + extension. rdrecord, rdsamp and rdheader already accept path-like objects, so rdann now converts record_name with os.fspath at the start, and the docstring says str or os.PathLike.

This is the remaining part of #346, without the changes to how PhysioNet URLs are built.

Tests: reading sample-data/100 with a Path gives the same annotations as with a string (this fails on main), and reading from a .wfdb archive given as a Path works too.

rdann built the annotation file name with record_name + "." + extension,
which fails for a pathlib.Path. Convert record_name with os.fspath at the
start, as rdrecord, rdsamp and rdheader already accept path-like objects.
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