forked from IPKM/nmreval
1/p bounds in ui
This commit is contained in:
parent
207ee5bffd
commit
a97c31325f
@ -86,15 +86,21 @@ class FitModelWidget(QtWidgets.QWidget, Ui_FitParameter):
|
|||||||
p = self.parameter_line.text().replace(',', '.')
|
p = self.parameter_line.text().replace(',', '.')
|
||||||
|
|
||||||
if self.checkBox.isChecked():
|
if self.checkBox.isChecked():
|
||||||
try:
|
lb_text = self.lineEdit.text()
|
||||||
lb = float(self.lineEdit.text().replace(',', '.'))
|
lb = None
|
||||||
except ValueError:
|
if lb_text:
|
||||||
lb = None
|
try:
|
||||||
|
lb = float(lb_text.replace(',', '.'))
|
||||||
|
except ValueError:
|
||||||
|
lb = lb_text
|
||||||
|
|
||||||
try:
|
ub_text = self.lineEdit_2.text()
|
||||||
rb = float(self.lineEdit_2.text().replace(',', '.'))
|
rb = None
|
||||||
except ValueError:
|
if ub_text:
|
||||||
rb = None
|
try:
|
||||||
|
rb = float(ub_text.replace(',', '.'))
|
||||||
|
except ValueError:
|
||||||
|
rb = ub_text
|
||||||
else:
|
else:
|
||||||
lb = rb = None
|
lb = rb = None
|
||||||
|
|
||||||
|
@ -278,10 +278,12 @@ class FitRoutine(object):
|
|||||||
data._model = self.fit_model
|
data._model = self.fit_model
|
||||||
self._no_own_model.append(data)
|
self._no_own_model.append(data)
|
||||||
|
|
||||||
|
data.parameter.prepare_bounds()
|
||||||
|
|
||||||
return self._prep_parameter(data.parameter)
|
return self._prep_parameter(data.parameter)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _prep_parameter(parameter):
|
def _prep_parameter(parameter: Parameters):
|
||||||
vals = []
|
vals = []
|
||||||
var_pars = []
|
var_pars = []
|
||||||
for p_k, v_k in parameter.items():
|
for p_k, v_k in parameter.items():
|
||||||
@ -293,7 +295,8 @@ class FitRoutine(object):
|
|||||||
|
|
||||||
return pp, lb, ub, var_pars
|
return pp, lb, ub, var_pars
|
||||||
|
|
||||||
def _prep_global(self, data_group, linked):
|
@staticmethod
|
||||||
|
def _prep_global(data_group: list[Data], linked):
|
||||||
p0 = []
|
p0 = []
|
||||||
lb = []
|
lb = []
|
||||||
ub = []
|
ub = []
|
||||||
@ -306,6 +309,8 @@ class FitRoutine(object):
|
|||||||
for k, v in data.model.parameter.items():
|
for k, v in data.model.parameter.items():
|
||||||
data.replace_parameter(k, v)
|
data.replace_parameter(k, v)
|
||||||
|
|
||||||
|
data.parameter.prepare_bounds()
|
||||||
|
|
||||||
actual_pars = []
|
actual_pars = []
|
||||||
for i, p_k in enumerate(data.para_keys):
|
for i, p_k in enumerate(data.para_keys):
|
||||||
p_k_used = p_k
|
p_k_used = p_k
|
||||||
|
@ -102,10 +102,12 @@ class Parameters(dict):
|
|||||||
p._expr = expression
|
p._expr = expression
|
||||||
|
|
||||||
def prepare_bounds(self):
|
def prepare_bounds(self):
|
||||||
|
print('prepare_bounds')
|
||||||
original_values = list(self.values())
|
original_values = list(self.values())
|
||||||
for param in original_values:
|
for param in original_values:
|
||||||
already_with_expression = False
|
already_with_expression = False
|
||||||
for mode, value in (('lower', param.lb), ('upper', param.ub)):
|
for mode, value in (('lower', param.lb), ('upper', param.ub)):
|
||||||
|
print(mode, value)
|
||||||
if already_with_expression:
|
if already_with_expression:
|
||||||
raise ValueError('Only one boundary can be an expression')
|
raise ValueError('Only one boundary can be an expression')
|
||||||
already_with_expression = self.parse(param, value, bnd=mode)
|
already_with_expression = self.parse(param, value, bnd=mode)
|
||||||
|
Loading…
Reference in New Issue
Block a user