From cc7ffe94f951ebeb87bbdf876875af9df8baf371 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 30 Nov 2020 14:35:19 +0100 Subject: pelt: allow disabling multiprocessing --- lib/pelt.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pelt.py b/lib/pelt.py index 8858533..38fb158 100644 --- a/lib/pelt.py +++ b/lib/pelt.py @@ -38,6 +38,7 @@ class PELT: self.refinement_threshold = 200e-6 # 200 µW self.range_min = 0 self.range_max = 100 + self.with_multiprocessing = True self.__dict__.update(kwargs) # signals: a set of uW measurements belonging to a single parameter configuration (i.e., a single by_param entry) @@ -79,8 +80,11 @@ class PELT: queue = list() for i in range(0, 100): queue.append((algo, i)) - with Pool() as pool: - changepoints = pool.starmap(PELT_get_changepoints, queue) + if self.with_multiprocessing: + with Pool() as pool: + changepoints = pool.starmap(PELT_get_changepoints, queue) + else: + changepoints = map(lambda x: PELT_get_changepoints(*x), queue) changepoints_by_penalty = dict() for res in changepoints: if len(res[1]) > 0 and res[1][-1] == len(signal): -- cgit v1.2.3