Repository navigation
Document and test what the XQRS backsearch skip relies on - #598
Merged
tompollard merged 2 commits intoOct 31, 2026
Merged
Conversation
The skip added in #596 is only correct while _update_noise leaves qrs_thr alone and _update_qrs moves last_qrs_peak_num to the current peak. Name both in the comment and add a test that fails if either changes.
tompollard
approved these changes
Oct 31, 2026
tompollard
left a comment
Member
There was a problem hiding this comment.
Thanks @TheNetherWatcher, this looks good! Checking the two assumptions directly makes sense.
One small optional addition: the comment says the result depends on qrs_thr and last_qrs_ind, but noise_spy only checks qrs_thr.
Checking both would cover the comment fully:
def noise_spy(peak_num):
qrs_thr, last_qrs_ind = xqrs.qrs_thr, xqrs.last_qrs_ind
update_noise(peak_num)
assert (xqrs.qrs_thr, xqrs.last_qrs_ind) == (qrs_thr, last_qrs_ind)Happy to merge as it is, or with that change.
Contributor
Author
|
Thanks! Good point, I've added it. The noise check now compares |
Member
|
Looks good to me, thanks @TheNetherWatcher! |
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.
Closes #597.
The skip added in #596 is only correct while two things stay true:
_update_noisedoesn't changeqrs_thr._update_qrssetslast_qrs_peak_numto the current peak.This PR:
_backsearch.test_xqrs_backsearch_skip_assumptions, which runs XQRS on record 100 with a 2-minute low-amplitude gap followed by scaled-down beats (so backsearch actually finds QRS complexes) and checks both properties after every update.I first tried a test comparing the skip against a full rescan, but it still passed when I broke either property, because the data never hit the case where they matter. The direct check fails for both changes:
_update_noisealso recalculatingqrs_thr→ fails_update_qrssettinglast_qrs_peak_num = peak_num→ failsNo change in behaviour, so no changelog entry.
ruff checkis clean andpytest -m "not network"passes (83 tests).