From 6d2848d5a5c3add351d0f9160fcaf8f089e1f35b Mon Sep 17 00:00:00 2001 From: Marko Toplak Date: Thu, 25 Apr 2024 17:30:30 +0200 Subject: [PATCH] lmfit: remove constant hack --- .tox.ini.swp | Bin 0 -> 4096 bytes conda/meta.yaml | 2 +- orangecontrib/spectroscopy/widgets/owpeakfit.py | 7 +++---- .../spectroscopy/widgets/peakfit_compute.py | 13 ++----------- setup.py | 2 +- tox.ini | 2 +- 6 files changed, 8 insertions(+), 18 deletions(-) create mode 100644 .tox.ini.swp diff --git a/.tox.ini.swp b/.tox.ini.swp new file mode 100644 index 0000000000000000000000000000000000000000..e36c250cbeedb9ccdab4b9083467cb6054bc2ed6 GIT binary patch literal 4096 zcmYc?2=nw+u+TGP00IF9hS_J9r(Vt9$}mM)f+07tC_5h{P5|U(rY9N^Py>>#0~@HH zl3J#pUzC`ao~m11keXallwX{jUr?!El3$^hnU_g~L8D4WLtr!nNDG0|k~Ccl-cVyB wLj#aTWhF%gVWCjc%otTY8UmvsFd71*Aut*OqaiRF0;3@?8UmvsFr-5O01VF_OaK4? literal 0 HcmV?d00001 diff --git a/conda/meta.yaml b/conda/meta.yaml index 44a876cd6..75e261e86 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -38,7 +38,7 @@ requirements: - extranormal3 >=0.0.3 - renishawWiRE >=0.1.8 - pillow - - lmfit >=1.0.2 + - lmfit >=1.3.1 - bottleneck - pebble - agilent-format>=0.4.5 diff --git a/orangecontrib/spectroscopy/widgets/owpeakfit.py b/orangecontrib/spectroscopy/widgets/owpeakfit.py index ec833d514..f5d99752e 100644 --- a/orangecontrib/spectroscopy/widgets/owpeakfit.py +++ b/orangecontrib/spectroscopy/widgets/owpeakfit.py @@ -33,7 +33,7 @@ ThermalDistributionModelEditor, DoniachModelEditor, ConstantModelEditor, \ LinearModelEditor, QuadraticModelEditor, PolynomialModelEditor, set_default_vary from orangecontrib.spectroscopy.widgets.peakfit_compute import n_best_fit_parameters, \ - best_fit_results, LMFIT_LOADS_KWARGS, pool_initializer, pool_fit, pool_fit2 + best_fit_results, pool_initializer, pool_fit, pool_fit2 # number of processes used for computation N_PROCESSES = None @@ -264,8 +264,7 @@ def progress_interrupt(_: float): raise concurrent.futures.wait([res], 0.05) fits = res.result() - model_result[row.id] = ModelResult(model, parameters).loads(fits, - **LMFIT_LOADS_KWARGS) + model_result[row.id] = ModelResult(model, parameters).loads(fits) progress_interrupt(0) return orig_data, data, model_result @@ -393,7 +392,7 @@ def done(): progress_interrupt(99) for fit, bpar, fitted, resid in fitsr: - out = ModelResult(model, parameters).loads(fit, **LMFIT_LOADS_KWARGS) + out = ModelResult(model, parameters).loads(fit) output.append(bpar) fits.append(fitted) residuals.append(resid) diff --git a/orangecontrib/spectroscopy/widgets/peakfit_compute.py b/orangecontrib/spectroscopy/widgets/peakfit_compute.py index 9c405f914..10c2bf15c 100644 --- a/orangecontrib/spectroscopy/widgets/peakfit_compute.py +++ b/orangecontrib/spectroscopy/widgets/peakfit_compute.py @@ -6,15 +6,6 @@ import numpy as np -def constant(x, c=0.0): - return c - - -# WORKAROUND lmfit's inability to load constant models -# Add this as kwargs to .loads -LMFIT_LOADS_KWARGS = {"funcdefs": {"constant": constant}} - - def n_best_fit_parameters(model, params): """Number of output parameters for best fit results""" number_of_peaks = len(model.components) @@ -54,7 +45,7 @@ def pool_initializer(model, parameters, x): # Therefore we need to use loads() and dumps() to transfer it between processes. global lmfit_model global lmfit_x - lmfit_model = Model(None).loads(model, **LMFIT_LOADS_KWARGS), parameters + lmfit_model = Model(None).loads(model), parameters lmfit_x = x @@ -73,6 +64,6 @@ def pool_fit(v): def pool_fit2(v, model, parameters, x): - model = Model(None).loads(model, **LMFIT_LOADS_KWARGS) + model = Model(None).loads(model) model_result = model.fit(v, params=parameters, x=x) return model_result.dumps() diff --git a/setup.py b/setup.py index 4fae83166..f7129b557 100644 --- a/setup.py +++ b/setup.py @@ -142,7 +142,7 @@ def include_documentation(local_dir, install_dir): 'extranormal3 >=0.0.3', 'renishawWiRE>=0.1.8', 'pillow', - 'lmfit>=1.0.2', + 'lmfit>=1.3.1', 'bottleneck', 'pebble', 'agilent-format>=0.4.5' diff --git a/tox.ini b/tox.ini index 663cec2a1..ea9cf85e8 100644 --- a/tox.ini +++ b/tox.ini @@ -30,7 +30,7 @@ deps = oldest: scipy~=1.9.0 oldest: pandas~=1.3.0 oldest: spectral~=0.22.3 - oldest: lmfit~=1.0.2 + oldest: lmfit==1.3.1 latest: https://github.com/biolab/orange3/archive/refs/heads/master.zip#egg=orange3 latest: https://github.com/biolab/orange-canvas-core/archive/refs/heads/master.zip#egg=orange-canvas-core latest: https://github.com/biolab/orange-widget-base/archive/refs/heads/master.zip#egg=orange-widget-base