From 12726e6f5620e7e54a0a8e8674c753fcbd834a2a Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Thu, 30 Nov 2023 17:47:53 +0100 Subject: [PATCH] set order is now respected for fits; fixes #161 --- src/gui_qt/fit/result.py | 2 -- src/gui_qt/main/management.py | 21 ++++++--------------- src/nmreval/fit/parameter.py | 2 -- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/gui_qt/fit/result.py b/src/gui_qt/fit/result.py index 45dfee3..4ad9e48 100644 --- a/src/gui_qt/fit/result.py +++ b/src/gui_qt/fit/result.py @@ -211,8 +211,6 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog): self.fit_plot.setLogMode(x=res.islog) self.resid_plot.setLogMode(x=res.islog) - print(self.graph_opts) - if idx in self.graph_opts: view_range, logx, logy = self.graph_opts[idx] self.fit_plot.setLogMode(x=logx, y=logy) diff --git a/src/gui_qt/main/management.py b/src/gui_qt/main/management.py index fb24633..a4f7db5 100644 --- a/src/gui_qt/main/management.py +++ b/src/gui_qt/main/management.py @@ -302,7 +302,6 @@ class UpperManagement(QtCore.QObject): @QtCore.pyqtSlot() def delete_sets(self, rm_sets: list = None): rm_graphs = [] - print(rm_sets) if rm_sets is None: 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') 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) self.undostack.push(cmd) for k in rm_graphs: - print('delete graphs') cmd = DeleteGraphCommand(self.graphs, k, self.restoreGraph, self.deleteGraph) self.undostack.push(cmd) @@ -456,6 +453,11 @@ class UpperManagement(QtCore.QObject): 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 try: for model_id, model_p in parameter.items(): @@ -464,18 +466,7 @@ class UpperManagement(QtCore.QObject): m_complex = model_p['complex'] - # 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 - 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] - + for set_id in list_ids: try: data_i = self.data[set_id] except KeyError as e: diff --git a/src/nmreval/fit/parameter.py b/src/nmreval/fit/parameter.py index 65a320b..c1c2625 100644 --- a/src/nmreval/fit/parameter.py +++ b/src/nmreval/fit/parameter.py @@ -102,12 +102,10 @@ class Parameters(dict): p._expr = expression def prepare_bounds(self): - print('prepare_bounds') original_values = list(self.values()) for param in original_values: already_with_expression = False for mode, value in (('lower', param.lb), ('upper', param.ub)): - print(mode, value) if already_with_expression: raise ValueError('Only one boundary can be an expression') already_with_expression = self.parse(param, value, bnd=mode)