diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2020-11-30 14:35:19 +0100 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2020-11-30 14:35:19 +0100 |
commit | cc7ffe94f951ebeb87bbdf876875af9df8baf371 (patch) | |
tree | f545d36be4e985fa7174e1f4342c8cff66f61149 /lib | |
parent | 17900d7687f96b68b1cefd8c78bce80e9161186c (diff) |
pelt: allow disabling multiprocessing
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pelt.py | 8 |
1 files changed, 6 insertions, 2 deletions
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): |