Skip to content

Commit

Permalink
Merge pull request Quasars#721 from stuart-cls/test-peakfit-dumpload
Browse files Browse the repository at this point in the history
[TEST] Add a test to check peakfit_compute.pool_initializer restore
  • Loading branch information
markotoplak authored May 14, 2024
2 parents 54537d7 + b3aa81e commit 142a0da
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions orangecontrib/spectroscopy/tests/test_owpeakfit.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from orangecontrib.spectroscopy.widgets.peak_editors import ParamHintBox, VoigtModelEditor, \
PseudoVoigtModelEditor, ExponentialGaussianModelEditor, PolynomialModelEditor, \
GaussianModelEditor

import orangecontrib.spectroscopy.widgets.peakfit_compute as peakfit_compute

# shorter initializations in tests
owpeakfit.N_PROCESSES = 1
Expand All @@ -45,23 +45,14 @@ def test_allint_indv(self):
with self.subTest(msg=f"Testing model {p.name}"):
settings = None
if p.viewclass == PolynomialModelEditor:
continue
self.skipTest("Polynomial Model does not converge on this data")
if p.viewclass == ExponentialGaussianModelEditor:
settings = {'storedsettings':
{'name': '',
'preprocessors':
[('orangecontrib.spectroscopy.widgets.owwidget.eg',
{'center': OrderedDict([('value', 1650.0)]),
'sigma': OrderedDict([('value', 5.0),
('max', 20.0)]),
'gamma': OrderedDict([('value', 1.0),
('vary', "fixed")]),
})]}}
self.skipTest("Exponential Gaussian Model does not converge on this data")
elif p.viewclass == PseudoVoigtModelEditor:
settings = {'storedsettings':
{'name': '',
'preprocessors':
[('orangecontrib.spectroscopy.widgets.owwidget.pv',
[('orangecontrib.spectroscopy.widgets.peak_editors.pv',
{'center': OrderedDict([('value', 1650.0)]),
'fraction': OrderedDict([('vary', "fixed")]),
})]}}
Expand Down Expand Up @@ -159,6 +150,13 @@ def test_fit_peaks(self):
out = fit_peaks(self.data, model, params)
assert len(out) == len(self.data)

def test_peakfit_compute_dumpload(self):
model = lmfit.models.VoigtModel(prefix="v1_")
params = model.make_params(center=1655)
x = getx(self.data)
peakfit_compute.pool_initializer(model.dumps(), params, x)
assert peakfit_compute.lmfit_model[0].dumps() == model.dumps()

def test_table_output(self):
pcs = [1547, 1655]
mlist = [lmfit.models.VoigtModel(prefix=f"v{i}_") for i in range(len(pcs))]
Expand Down

0 comments on commit 142a0da

Please sign in to comment.