1
0
forked from IPKM/nmreval

set order is now respected for fits; fixes #161

This commit is contained in:
Dominik Demuth 2023-11-30 17:47:53 +01:00
parent d146f4fe7e
commit 12726e6f56
3 changed files with 6 additions and 19 deletions

View File

@ -211,8 +211,6 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog):
self.fit_plot.setLogMode(x=res.islog) self.fit_plot.setLogMode(x=res.islog)
self.resid_plot.setLogMode(x=res.islog) self.resid_plot.setLogMode(x=res.islog)
print(self.graph_opts)
if idx in self.graph_opts: if idx in self.graph_opts:
view_range, logx, logy = self.graph_opts[idx] view_range, logx, logy = self.graph_opts[idx]
self.fit_plot.setLogMode(x=logx, y=logy) self.fit_plot.setLogMode(x=logx, y=logy)

View File

@ -302,7 +302,6 @@ class UpperManagement(QtCore.QObject):
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def delete_sets(self, rm_sets: list = None): def delete_sets(self, rm_sets: list = None):
rm_graphs = [] rm_graphs = []
print(rm_sets)
if rm_sets is None: if rm_sets is None:
rm_sets = self.graphs[self.current_graph].sets + [self.current_graph] rm_sets = self.graphs[self.current_graph].sets + [self.current_graph]
@ -330,12 +329,10 @@ class UpperManagement(QtCore.QObject):
logger.warning(f'delete_sets: {k} is not in data or graph found') logger.warning(f'delete_sets: {k} is not in data or graph found')
for gid, sid_list in rm_set_by_graph.items(): for gid, sid_list in rm_set_by_graph.items():
print('delete set')
cmd = DeleteCommand(self.data, list(sid_list), self.graphs, gid, self.newData, self.deleteData) cmd = DeleteCommand(self.data, list(sid_list), self.graphs, gid, self.newData, self.deleteData)
self.undostack.push(cmd) self.undostack.push(cmd)
for k in rm_graphs: for k in rm_graphs:
print('delete graphs')
cmd = DeleteGraphCommand(self.graphs, k, self.restoreGraph, self.deleteGraph) cmd = DeleteGraphCommand(self.graphs, k, self.restoreGraph, self.deleteGraph)
self.undostack.push(cmd) self.undostack.push(cmd)
@ -456,6 +453,11 @@ class UpperManagement(QtCore.QObject):
self.fitter.fitmethod = fit_mode self.fitter.fitmethod = fit_mode
# sets are not in active order but in order they first appeared in fit dialog
# iterate over order of set id in active order and access parameter inside loop
# instead of directly looping
list_ids = list(self.active_id)
# all-encompassing error catch # all-encompassing error catch
try: try:
for model_id, model_p in parameter.items(): for model_id, model_p in parameter.items():
@ -464,18 +466,7 @@ class UpperManagement(QtCore.QObject):
m_complex = model_p['complex'] m_complex = model_p['complex']
# sets are not in active order but in order they first appeared in fit dialog for set_id in list_ids:
# iterate over order of set id in active order and access parameter inside loop
# instead of directly looping
try:
list_ids = list(self.active_id)
set_order = [self.active_id.index(i) for i in model_p['data_parameter'].keys()]
except ValueError as e:
raise Exception('Getting order failed') from e
for pos in set_order:
set_id = list_ids[pos]
try: try:
data_i = self.data[set_id] data_i = self.data[set_id]
except KeyError as e: except KeyError as e:

View File

@ -102,12 +102,10 @@ class Parameters(dict):
p._expr = expression p._expr = expression
def prepare_bounds(self): def prepare_bounds(self):
print('prepare_bounds')
original_values = list(self.values()) original_values = list(self.values())
for param in original_values: for param in original_values:
already_with_expression = False already_with_expression = False
for mode, value in (('lower', param.lb), ('upper', param.ub)): for mode, value in (('lower', param.lb), ('upper', param.ub)):
print(mode, value)
if already_with_expression: if already_with_expression:
raise ValueError('Only one boundary can be an expression') raise ValueError('Only one boundary can be an expression')
already_with_expression = self.parse(param, value, bnd=mode) already_with_expression = self.parse(param, value, bnd=mode)