From 1601f1455c05e60e7351d7f9cf4904b378722186 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Wed, 1 Mar 2023 19:26:12 +0100 Subject: [PATCH] use same value in widget and multimodel to count parameter --- src/gui_qt/fit/fitwindow.py | 11 ++++++----- src/nmreval/fit/_meta.py | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/gui_qt/fit/fitwindow.py b/src/gui_qt/fit/fitwindow.py index 099dd1c..60ea5b2 100644 --- a/src/gui_qt/fit/fitwindow.py +++ b/src/gui_qt/fit/fitwindow.py @@ -4,7 +4,6 @@ from functools import reduce from itertools import count, cycle from operator import add from string import ascii_letters -from typing import Dict, List, Tuple import numpy as np from pyqtgraph import mkPen @@ -144,7 +143,7 @@ class QFitDialog(QtWidgets.QWidget, Ui_FitDialog): self._complex[self._current_model] = self.functionwidget.get_complex_state() self._func_list[self._current_model] = self.functionwidget.get_parameter_list() - def load(self, ids: List[str]): + def load(self, ids: list[str]): """ Add name and id of dataset to list. """ @@ -216,7 +215,7 @@ class QFitDialog(QtWidgets.QWidget, Ui_FitDialog): self.model_frame.hide() def _prepare(self, model: list, function_use: list = None, - parameter: dict = None, add_idx: bool = False, cnt: int = 0) -> Tuple[dict, int]: + parameter: dict = None, add_idx: bool = False, cnt: int = 0) -> tuple[dict, int]: if parameter is None: parameter = {'parameter': {}, 'lb': (), 'ub': (), 'var': [], 'glob': {'idx': [], 'p': [], 'var': [], 'lb': [], 'ub': []}, @@ -241,6 +240,8 @@ class QFitDialog(QtWidgets.QWidget, Ui_FitDialog): parameter['links'] += links parameter['color'] += [f['color']] + cnt = f['cnt'] + for p_k, v_k in p.items(): if add_idx: kw_k = {f'{k}_{cnt}': v for k, v in v_k[1].items()} @@ -450,7 +451,7 @@ class QFitDialog(QtWidgets.QWidget, Ui_FitDialog): return self.preview_lines - def set_parameter(self, parameter: Dict[str, FitResult]): + def set_parameter(self, parameter: dict[str, FitResult]): # which data uses which model data = self.data_table.collect_data(default=self.default_combobox.currentData()) @@ -468,7 +469,7 @@ class QFitDialog(QtWidgets.QWidget, Ui_FitDialog): self.set_parameter_iter(None, mean_parameter, self.models[fitted_model]) - def set_parameter_iter(self, fit_id: str | None, param: List[float], functions: List, cnt: int = 0): + def set_parameter_iter(self, fit_id: str | None, param: list[float], functions: list, cnt: int = 0): for model_p in functions: if model_p['active']: cnt += self.param_widgets[model_p['cnt']].set_parameter(fit_id, param[cnt:]) diff --git a/src/nmreval/fit/_meta.py b/src/nmreval/fit/_meta.py index e8b101f..230cb68 100644 --- a/src/nmreval/fit/_meta.py +++ b/src/nmreval/fit/_meta.py @@ -29,7 +29,7 @@ class ModelFactory: right_cnt = None else: right = func['func'] - right_cnt = func['pos'] + right_cnt = func['cnt'] if left is None: left = right