From 34cd6f989de6a7f1eec27d8390b179c0f943e2a4 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 15 Jan 2021 11:03:00 +0100 Subject: pelt: Fix Dynp support --- lib/pelt.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pelt.py b/lib/pelt.py index bd79c9b..95e828a 100644 --- a/lib/pelt.py +++ b/lib/pelt.py @@ -102,12 +102,16 @@ class PELT: changepoints = algo.predict(pen=penalty) if len(changepoints) and changepoints[-1] == len(signal): changepoints.pop() + if len(changepoints) and changepoints[0] == 0: + changepoints.pop(0) return penalty, changepoints if self.algo == "dynp" and num_changepoints is not None: - changepoints = algo.predict(pen=penalty) + changepoints = algo.predict(n_bkps=num_changepoints) if len(changepoints) and changepoints[-1] == len(signal): changepoints.pop() + if len(changepoints) and changepoints[0] == 0: + changepoints.pop(0) return None, changepoints queue = list() -- cgit v1.2.3