Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions tests/test_processing.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from unittest import mock

import numpy as np

import wfdb
Expand Down Expand Up @@ -199,3 +201,28 @@ def test_xqrs(self):

assert comparitor.sensitivity > 0.99
assert comparitor.positive_predictivity > 0.99


class TestXQRSDetect:
"""
Tests for the xqrs_detect convenience wrapper.
"""

def test_xqrs_detect_forwards_learn(self):
"""
xqrs_detect should forward its learn argument to XQRS.detect
rather than silently dropping it (issue #473).
"""
sig, fields = wfdb.rdsamp("sample-data/100", channels=[0])

def fake_detect(self, *args, **kwargs):
# Stand in for the real detector so xqrs_detect can return.
self.qrs_inds = np.array([], dtype=int)

with mock.patch.object(
processing.XQRS, "detect", autospec=True, side_effect=fake_detect
) as mock_detect:
processing.xqrs_detect(sig=sig[:, 0], fs=fields["fs"], learn=False)

assert mock_detect.call_count == 1
assert mock_detect.call_args.kwargs["learn"] is False
2 changes: 1 addition & 1 deletion wfdb/processing/qrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ def xqrs_detect(

"""
xqrs = XQRS(sig=sig, fs=fs, conf=conf)
xqrs.detect(sampfrom=sampfrom, sampto=sampto, verbose=verbose)
xqrs.detect(sampfrom=sampfrom, sampto=sampto, learn=learn, verbose=verbose)
return xqrs.qrs_inds


Expand Down