From 3cdf2bf708acc715f2b62a54857578e1bd59586b Mon Sep 17 00:00:00 2001 From: Jonathan Shore Date: Mon, 19 Oct 2020 13:31:53 -0400 Subject: [PATCH] - fixed issue where labeler does not zero out filter section < minamp (contribution by Cory Fletcher) --- .../labelers/AmplitudeBasedLabeler.pyx | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/tseries_patterns/labelers/AmplitudeBasedLabeler.pyx b/tseries_patterns/labelers/AmplitudeBasedLabeler.pyx index 7becdf3..c2eb8be 100644 --- a/tseries_patterns/labelers/AmplitudeBasedLabeler.pyx +++ b/tseries_patterns/labelers/AmplitudeBasedLabeler.pyx @@ -333,18 +333,22 @@ cdef class AmplitudeBasedLabeler: Vmaxback = distance Imaxback = i - # label forward region if meets size requirement - if Vmaxfwd >= self.minamp: - self._apply_label (labels, Istart, Imaxfwd, dir) - self._apply_label (labels, Imaxfwd+1, Imaxback-1, 0.0) + # if neither direction meets required minimum, zero out + if Vmaxfwd < self.minamp and Vmaxback < self.minamp: + self._apply_label (labels, Istart, Iend, 0.0) else: - self._apply_label (labels, Istart, Imaxback, 0.0) + # label forward region if meets size requirement + if Vmaxfwd >= self.minamp: + self._apply_label (labels, Istart, Imaxfwd, dir) + self._apply_label (labels, Imaxfwd+1, Imaxback-1, 0.0) + else: + self._apply_label (labels, Istart, Imaxback, 0.0) - # label backward region is meets size requirement - if Vmaxback >= self.minamp: - self._apply_label (labels, Imaxback, Iend, dir) - else: - self._apply_label (labels, max(Imaxback, Imaxfwd+1), Iend, 0.0) + # label backward region if meets size requirement + if Vmaxback >= self.minamp: + self._apply_label (labels, Imaxback, Iend, dir) + else: + self._apply_label (labels, max(Imaxback, Imaxfwd+1), Iend, 0.0) Ipos = Iend+1