Unverified Commit 4819915b authored by Gagik Vardanyan's avatar Gagik Vardanyan Committed by GitHub
Browse files

Merge pull request #30414 from...

Merge pull request #30414 from mantidproject/30410_update_EngDiffUI_fit_browser_status_during_sequential_fitting

Update status of fit in fit browser during Sequential Fit in EngDiff UI
parents 960f7dcd 93a5e856
......@@ -73,6 +73,7 @@ Improvements
############
- The user is no longer asked to overwrite an automatically generated model that is saved in as a Custom Setup in the fit browser (it is overwritten).
- Generic Sequential Fit button removed from fit menu (users should use sequential fit button below the table in the fitting tab of the UI).
- Status of fit updated in fit browser when Sequential Fit performed in the fittinng tab of the UI.
New features
############
......
......@@ -594,7 +594,7 @@ signals:
void sequentialFitDone() const;
void workspaceClicked(const QString &);
void removePlotSignal(PropertyHandler *);
void fitResultsChanged(const QString &);
};
// ---------------------------------
......
......@@ -8,6 +8,7 @@ from mantidqt.utils.observer_pattern import GenericObserverWithArgPassing, Gener
from Engineering.gui.engineering_diffraction.tabs.fitting.plotting.plot_model import FittingPlotModel
from Engineering.gui.engineering_diffraction.tabs.fitting.plotting.plot_view import FittingPlotView
from mantid.simpleapi import Fit, logger
from copy import deepcopy
PLOT_KWARGS = {"linestyle": "", "marker": "x", "markersize": "3"}
......@@ -59,6 +60,8 @@ class FittingPlotPresenter(object):
fit_output = Fit(**fitprop['properties'])
fitprop['properties']['Function'] = str(fit_output.Function.fun)
# save setup in fitprop browser (updates browser for next iteration of loop)
self.view.update_browser_setup(fitprop['properties']['Function'], ws)
fitprop_list.append(fitprop)
self.view.update_browser(fit_output.OutputStatus, fitprop['properties']['Function'], ws)
# append a deep copy to output list
fitprop_list.append(deepcopy(fitprop))
logger.notice('Sequential fitting finished.')
self.seq_fit_done_notifier.notify_subscribers(fitprop_list)
......@@ -145,10 +145,12 @@ class FittingPlotView(QtWidgets.QWidget, Ui_plot):
def read_fitprop_from_browser(self):
return self.fit_browser.read_current_fitprop()
def update_browser_setup(self, func_str, setup_name):
# update browser with output function and save setup
self.fit_browser.loadFunction(func_str)
self.fit_browser.save_current_setup(setup_name)
def update_browser(self, status, func_str, setup_name):
self.fit_browser.fitResultsChanged.emit(status)
# update browser with output function and save setup if successful
if "success" in status:
self.fit_browser.loadFunction(func_str)
self.fit_browser.save_current_setup(setup_name)
# =================
# Component Getters
......
......@@ -60,7 +60,9 @@ class FittingPlotPresenterTest(unittest.TestCase):
in_fun_str = iter(fun_str_list[0:-1])
self.view.read_fitprop_from_browser.return_value = {'properties': {'Function': next(in_fun_str)}}
mock_fit_output = [mock.MagicMock(), mock.MagicMock()]
mock_fit_output[0].OutputStatus = "sucess"
mock_fit_output[0].Function.fun = fun_str_list[1]
mock_fit_output[1].OutputStatus = "fail"
mock_fit_output[1].Function.fun = fun_str_list[2]
mock_fit.side_effect = mock_fit_output
mock_notifier = mock.MagicMock()
......@@ -69,14 +71,17 @@ class FittingPlotPresenterTest(unittest.TestCase):
self.presenter.do_sequential_fit(ws_list)
self.assertEqual(mock_fit.call_count, len(ws_list))
fitprop_list = []
for iws, ws in enumerate(ws_list):
print(iws)
# check calls to fit
_, _, kwargs = mock_fit.mock_calls[iws]
self.assertEquals(kwargs, {'Function': fun_str_list[iws], 'InputWorkspace': ws, 'Output': ws})
# check update browser with fit results
_, args, _ = self.view.update_browser_setup.mock_calls[iws]
self.assertEquals(args, (fun_str_list[iws + 1], ws))
_, args, _ = self.view.update_browser.mock_calls[iws]
self.assertEquals(args, (mock_fit_output[iws].OutputStatus, fun_str_list[iws + 1], ws))
# collect all fitprop dicts together to test notifier
fitprop_list.append({'properties': {'Function': fun_str_list[iws + 1], 'InputWorkspace': ws, 'Output': ws}})
mock_notifier.notify_subscribers.assert_called_once_with(fitprop_list)
if __name__ == '__main__':
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment