From 4ad82cf5b283a4c584c2ede99b140a361d510682 Mon Sep 17 00:00:00 2001 From: dominik Date: Tue, 29 Mar 2022 09:16:02 +0200 Subject: [PATCH] bugfix: display fit parameter for single set --- nmreval/fit/parameter.py | 2 +- nmreval/gui_qt/data/datawidget/datawidget.py | 4 ++-- nmreval/gui_qt/fit/fitwindow.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nmreval/fit/parameter.py b/nmreval/fit/parameter.py index 12f92ed..cc18c85 100644 --- a/nmreval/fit/parameter.py +++ b/nmreval/fit/parameter.py @@ -118,7 +118,7 @@ class Parameter: return start + f'{self.value:} (fixed)' def __add__(self, other: Parameter | float) -> float: - if isinstance(other, float): + if isinstance(other, (float, int)): return self.value + other elif isinstance(other, Parameter): return self.value + other.value diff --git a/nmreval/gui_qt/data/datawidget/datawidget.py b/nmreval/gui_qt/data/datawidget/datawidget.py index 68b5ec3..ddc8fcb 100644 --- a/nmreval/gui_qt/data/datawidget/datawidget.py +++ b/nmreval/gui_qt/data/datawidget/datawidget.py @@ -1,4 +1,4 @@ -from typing import List, Union +from typing import List, Tuple, Union from .properties import PropWidget from ...Qt import QtWidgets, QtGui, QtCore @@ -77,7 +77,7 @@ class DataTree(QtWidgets.QTreeWidget): break @QtCore.pyqtSlot(QtWidgets.QTreeWidgetItem) - def data_change(self, item: QtWidgets.QTreeWidgetItem) -> tuple[set, set]: + def data_change(self, item: QtWidgets.QTreeWidgetItem) -> Tuple[set, set]: idd = item.data(0, QtCore.Qt.UserRole) is_selected = item.checkState(0) == QtCore.Qt.Checked to_be_hidden = set() diff --git a/nmreval/gui_qt/fit/fitwindow.py b/nmreval/gui_qt/fit/fitwindow.py index 320e83b..cff9c8e 100644 --- a/nmreval/gui_qt/fit/fitwindow.py +++ b/nmreval/gui_qt/fit/fitwindow.py @@ -443,7 +443,7 @@ class QFitDialog(QtWidgets.QWidget, Ui_FitDialog): self.set_parameter_iter(fit_id, [p.value for p in fit_parameter], self.models[fitted_model]) - mean_parameter = [reduce(add, p)/len(p) for p in zip(*glob_fit_parameter)] + mean_parameter = [reduce(add, p, 0)/len(p) for p in zip(*glob_fit_parameter)] self.set_parameter_iter(None, mean_parameter, self.models[fitted_model])