forked from IPKM/nmreval
use same value in widget and multimodel to count parameter
This commit is contained in:
parent
b73d6f08b8
commit
1601f1455c
@ -4,7 +4,6 @@ from functools import reduce
|
|||||||
from itertools import count, cycle
|
from itertools import count, cycle
|
||||||
from operator import add
|
from operator import add
|
||||||
from string import ascii_letters
|
from string import ascii_letters
|
||||||
from typing import Dict, List, Tuple
|
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pyqtgraph import mkPen
|
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._complex[self._current_model] = self.functionwidget.get_complex_state()
|
||||||
self._func_list[self._current_model] = self.functionwidget.get_parameter_list()
|
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.
|
Add name and id of dataset to list.
|
||||||
"""
|
"""
|
||||||
@ -216,7 +215,7 @@ class QFitDialog(QtWidgets.QWidget, Ui_FitDialog):
|
|||||||
self.model_frame.hide()
|
self.model_frame.hide()
|
||||||
|
|
||||||
def _prepare(self, model: list, function_use: list = None,
|
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:
|
if parameter is None:
|
||||||
parameter = {'parameter': {}, 'lb': (), 'ub': (), 'var': [],
|
parameter = {'parameter': {}, 'lb': (), 'ub': (), 'var': [],
|
||||||
'glob': {'idx': [], 'p': [], 'var': [], 'lb': [], 'ub': []},
|
'glob': {'idx': [], 'p': [], 'var': [], 'lb': [], 'ub': []},
|
||||||
@ -241,6 +240,8 @@ class QFitDialog(QtWidgets.QWidget, Ui_FitDialog):
|
|||||||
parameter['links'] += links
|
parameter['links'] += links
|
||||||
parameter['color'] += [f['color']]
|
parameter['color'] += [f['color']]
|
||||||
|
|
||||||
|
cnt = f['cnt']
|
||||||
|
|
||||||
for p_k, v_k in p.items():
|
for p_k, v_k in p.items():
|
||||||
if add_idx:
|
if add_idx:
|
||||||
kw_k = {f'{k}_{cnt}': v for k, v in v_k[1].items()}
|
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
|
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
|
# which data uses which model
|
||||||
data = self.data_table.collect_data(default=self.default_combobox.currentData())
|
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])
|
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:
|
for model_p in functions:
|
||||||
if model_p['active']:
|
if model_p['active']:
|
||||||
cnt += self.param_widgets[model_p['cnt']].set_parameter(fit_id, param[cnt:])
|
cnt += self.param_widgets[model_p['cnt']].set_parameter(fit_id, param[cnt:])
|
||||||
|
@ -29,7 +29,7 @@ class ModelFactory:
|
|||||||
right_cnt = None
|
right_cnt = None
|
||||||
else:
|
else:
|
||||||
right = func['func']
|
right = func['func']
|
||||||
right_cnt = func['pos']
|
right_cnt = func['cnt']
|
||||||
|
|
||||||
if left is None:
|
if left is None:
|
||||||
left = right
|
left = right
|
||||||
|
Loading…
Reference in New Issue
Block a user