diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2021-08-19 09:50:40 +0200 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2021-08-19 09:50:40 +0200 |
commit | 26d07c8eae44d0a6919fd775728cdb1bb2808298 (patch) | |
tree | b0380add225649a5ccc16455856b8c508281a4ea /lib/paramfit.py | |
parent | 5312f01724edad7ef380ded9a6e34971b56c7939 (diff) |
ParallelParamFit -> ParamFit, optionally without parallelism
Diffstat (limited to 'lib/paramfit.py')
-rw-r--r-- | lib/paramfit.py | 16 |
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): """ |