From 66a0e40a23fcf59b973302cb7871076d0e671c48 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Fri, 19 May 2023 15:48:32 +0200 Subject: [PATCH] display correct start parameter --- src/gui_qt/fit/fit_parameter.py | 12 ++++++------ src/gui_qt/fit/fitwindow.py | 9 ++------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/gui_qt/fit/fit_parameter.py b/src/gui_qt/fit/fit_parameter.py index bcb3d1f..69b7301 100644 --- a/src/gui_qt/fit/fit_parameter.py +++ b/src/gui_qt/fit/fit_parameter.py @@ -263,17 +263,17 @@ class QFitParameterWidget(QtWidgets.QWidget, Ui_FormFit): return data_parameter, lb, ub, is_fixed, global_p, is_linked def set_parameter(self, set_id: str | None, parameter: list[float]) -> int: - param_len = len(list(filter(lambda g: not isinstance(g, SelectionWidget), self.global_parameter))) - + num_parameter = list(filter(lambda g: not isinstance(g, SelectionWidget), self.global_parameter)) + param_len = len(num_parameter) if set_id is None: - for val, g in zip(parameter, self.global_parameter): - if isinstance(g, SelectionWidget): - continue + for i, g in enumerate(num_parameter): + val = parameter[i] g.set_parameter(val) + self.glob_values[i] = val else: new_param = self.data_values[set_id] - min_len = min(param_len, len(new_param), len(new_param)) + min_len = min(param_len, len(new_param)) for i in range(min_len): new_param[i] = parameter[i] diff --git a/src/gui_qt/fit/fitwindow.py b/src/gui_qt/fit/fitwindow.py index 9a77171..5ba0ea6 100644 --- a/src/gui_qt/fit/fitwindow.py +++ b/src/gui_qt/fit/fitwindow.py @@ -77,16 +77,11 @@ class QFitDialog(QtWidgets.QWidget, Ui_FitDialog): w.deleteLater() del self.param_widgets[idx] - if len(self.functionwidget) == 0: + self._current_function = None + if len(self.param_widgets) == 0: # empty model self.newmodel_button.setEnabled(False) self.deletemodel_button.setEnabled(False) - self._current_function = None - - else: - f_tree = self.functionwidget.functree - func_idx = f_tree.currentItem().data(0, f_tree.counterRole) - self._current_function = self.functionwidget.functions[func_idx] @QtCore.pyqtSlot(int) def show_function_parameter(self, function_id: int, function_idx: int = None):