summaryrefslogtreecommitdiff
path: root/lib/paramfit.py
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2021-08-19 09:50:40 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2021-08-19 09:50:40 +0200
commit26d07c8eae44d0a6919fd775728cdb1bb2808298 (patch)
treeb0380add225649a5ccc16455856b8c508281a4ea /lib/paramfit.py
parent5312f01724edad7ef380ded9a6e34971b56c7939 (diff)
ParallelParamFit -> ParamFit, optionally without parallelism
Diffstat (limited to 'lib/paramfit.py')
-rw-r--r--lib/paramfit.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/paramfit.py b/lib/paramfit.py
index 8bc7505..5fdaf7a 100644
--- a/lib/paramfit.py
+++ b/lib/paramfit.py
@@ -17,7 +17,7 @@ from .utils import (
logger = logging.getLogger(__name__)
-class ParallelParamFit:
+class ParamFit:
"""
Fit a set of functions on parameterized measurements.
@@ -25,9 +25,10 @@ class ParallelParamFit:
function type for each parameter.
"""
- def __init__(self):
- """Create a new ParallelParamFit object."""
+ def __init__(self, parallel=True):
+ """Create a new ParamFit object."""
self.fit_queue = list()
+ self.parallel = parallel
def enqueue(self, key, param, args, kwargs=dict()):
"""
@@ -49,10 +50,13 @@ class ParallelParamFit:
Fitting is one in parallel with one process per core.
- Results can be accessed using the public ParallelParamFit.results object.
+ Results can be accessed using the public ParamFit.results object.
"""
- with Pool() as pool:
- self.results = pool.map(_try_fits_parallel, self.fit_queue)
+ if self.parallel:
+ with Pool() as pool:
+ self.results = pool.map(_try_fits_parallel, self.fit_queue)
+ else:
+ self.results = list(map(_try_fits_parallel, self.fit_queue))
def get_result(self, key):
"""