From 4b880eccfc143d7ee933817e1f6be016a290f789 Mon Sep 17 00:00:00 2001 From: Arpit Jain Date: Fri, 26 Jun 2026 12:03:46 +0900 Subject: [PATCH] Forward learn argument from xqrs_detect to XQRS.detect xqrs_detect accepts a learn parameter and documents it, but the call to XQRS.detect never passed it on, so learn=False was silently ignored and learning always ran. Pass learn=learn through to the detector and add a regression test that asserts the argument is forwarded. Closes #473 Signed-off-by: Arpit Jain --- tests/test_processing.py | 27 +++++++++++++++++++++++++++ wfdb/processing/qrs.py | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/tests/test_processing.py b/tests/test_processing.py index 0f371660..f9dce746 100644 --- a/tests/test_processing.py +++ b/tests/test_processing.py @@ -1,3 +1,5 @@ +from unittest import mock + import numpy as np import wfdb @@ -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 diff --git a/wfdb/processing/qrs.py b/wfdb/processing/qrs.py index 6f2f4bc4..3460ec13 100644 --- a/wfdb/processing/qrs.py +++ b/wfdb/processing/qrs.py @@ -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