Repository navigation
Ignore an invalid base time or date in a header, with a warning - #668
Merged
Merged
Conversation
rdheader raised a ValueError when the base date in the record line was not a DD/MM/YYYY date (such as 25.12.2020, 2020-12-25 or a year alone), so the whole record could not be read. Like the WFDB library, ignore such a date with a warning, and read the rest of the header. Fixes #415.
The record line pattern takes the parts of the line that look like a time and a date, so "05-Feb-2020 11:39:16" was read as a base time of 5 seconds, and a year alone in place of the time raised a ValueError. Read the base time and date as the fifth and sixth fields instead, and ignore either one, with a warning, if it is not valid.
tompollard
commented
Nov 23, 2026
tompollard
left a comment
Member
Author
There was a problem hiding this comment.
Reviewed 4c54609. The parser handles invalid base time and date fields by warning and continuing, while valid header behavior remains intact. I found no actionable issues. All 110 focused offline record tests and all 18 PR checks pass. Looks good to merge from my review.
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.
Fixes #415.
rdheader, and sordrecordandrdsamp, could not read a record whose header has a base time or date in another form:10:30:00 25.12.2020(or2020-12-25,31/02/2020)ValueError2020(a year in place of the time)ValueError05-Feb-2020 11:39:16(2020 and 2021 Challenges)As the issue suggests, this follows the WFDB library, which ignores a date that isn't DD/MM/YYYY and reads the rest of the record. The base time and date are now read as the fifth and sixth fields of the record line, not as whatever part of the line the record line pattern matches, so a value in another form is never read in part. Valid headers are read as before: the base time and date of all 88 headers in
sample-dataare the same as onmain.Writing is unchanged:
wrheaderwritesbase_timeandbase_datefromdatetimeobjects, which are always in the WFDB form.Testing
main.pytest: all offline and network tests pass. Ruff and the docs build pass.@tompollard 🟥 red 🦥 sloth · aspen