sub function show numbering; closes #70
This commit is contained in:
parent
2adf15104f
commit
65034d4518
@ -653,12 +653,10 @@ class UpperManagement(QtCore.QObject):
|
|||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for key, pvalue in data.parameter.items():
|
for fit_key, pvalue in data.parameter.items():
|
||||||
name = pvalue.full_name
|
|
||||||
fit_key = key + data.model_name
|
|
||||||
|
|
||||||
if fit_key not in fit_dict:
|
if fit_key not in fit_dict:
|
||||||
fit_dict[fit_key] = [[], name]
|
fit_dict[fit_key] = [[], fit_key]
|
||||||
|
|
||||||
err = 0 if pvalue.error is None else pvalue.error
|
err = 0 if pvalue.error is None else pvalue.error
|
||||||
|
|
||||||
|
@ -68,6 +68,7 @@ class MultiModel:
|
|||||||
self._kwargs_right = {}
|
self._kwargs_right = {}
|
||||||
self._kwargs_left = {}
|
self._kwargs_left = {}
|
||||||
self.fun_kwargs = {}
|
self.fun_kwargs = {}
|
||||||
|
self.idx = (left_idx, right_idx)
|
||||||
|
|
||||||
# mapping kwargs to kwargs of underlying functions
|
# mapping kwargs to kwargs of underlying functions
|
||||||
self._ext_int_kw = {}
|
self._ext_int_kw = {}
|
||||||
@ -178,13 +179,13 @@ class MultiModel:
|
|||||||
if isinstance(self._left, MultiModel):
|
if isinstance(self._left, MultiModel):
|
||||||
yield from self._left.sub_name()
|
yield from self._left.sub_name()
|
||||||
elif hasattr(self._left, 'name'):
|
elif hasattr(self._left, 'name'):
|
||||||
yield self._left.name
|
yield f'{self._left.name}({self.idx[0]})'
|
||||||
else:
|
else:
|
||||||
yield self.name + '(lhs)'
|
yield self.name + '(lhs)'
|
||||||
|
|
||||||
if isinstance(self._right, MultiModel):
|
if isinstance(self._right, MultiModel):
|
||||||
yield from self._right.sub_name()
|
yield from self._right.sub_name()
|
||||||
elif hasattr(self._right, 'name'):
|
elif hasattr(self._right, 'name'):
|
||||||
yield self._right.name
|
yield f'{self._right.name}({self.idx[1]})'
|
||||||
else:
|
else:
|
||||||
yield self.name + '(rhs)'
|
yield self.name + '(rhs)'
|
||||||
|
@ -65,17 +65,21 @@ class FitResultCreator:
|
|||||||
|
|
||||||
resid = model.func(p_final, x_orig, **fun_kwargs) - y_orig
|
resid = model.func(p_final, x_orig, **fun_kwargs) - y_orig
|
||||||
|
|
||||||
actual_complex_mode = 0
|
actual_mode = -1
|
||||||
if 'complex_mode' in fun_kwargs:
|
if 'complex_mode' in fun_kwargs:
|
||||||
actual_complex_mode = fun_kwargs['complex_mode']
|
actual_mode = fun_kwargs['complex_mode']
|
||||||
fun_kwargs['complex_mode'] = 0
|
fun_kwargs['complex_mode'] = 0
|
||||||
|
|
||||||
_y = model.func(p_final, _x, **fun_kwargs)
|
_y = model.func(p_final, _x, **fun_kwargs)
|
||||||
if actual_complex_mode == 1:
|
|
||||||
|
if not actual_mode < 0:
|
||||||
|
if actual_mode == 1:
|
||||||
_y.imag = 0
|
_y.imag = 0
|
||||||
elif actual_complex_mode == 2:
|
elif actual_mode == 2:
|
||||||
_y.real = 0
|
_y.real = 0
|
||||||
|
|
||||||
|
fun_kwargs['complex_mode'] = actual_mode
|
||||||
|
|
||||||
stats = FitResultCreator.calc_statistics(_y, resid, nobs, nvar)
|
stats = FitResultCreator.calc_statistics(_y, resid, nobs, nvar)
|
||||||
varied = [p.var for p in parameters.values()]
|
varied = [p.var for p in parameters.values()]
|
||||||
|
|
||||||
@ -368,18 +372,45 @@ class FitResult(Points):
|
|||||||
if self.func is None:
|
if self.func is None:
|
||||||
raise ValueError('no fit function available to calculate new y values')
|
raise ValueError('no fit function available to calculate new y values')
|
||||||
|
|
||||||
|
actual_mode = -1
|
||||||
|
if 'complex_mode' in self.fun_kwargs:
|
||||||
|
actual_mode = self.fun_kwargs['complex_mode']
|
||||||
|
self.fun_kwargs['complex_mode'] = 0
|
||||||
|
|
||||||
new_fit = self.copy()
|
new_fit = self.copy()
|
||||||
y_values = self.func.func(self.p_final, x_values, **self.fun_kwargs)
|
y_values = self.func.func(self.p_final, x_values, **self.fun_kwargs)
|
||||||
|
if not actual_mode < 0:
|
||||||
|
if actual_mode == 1:
|
||||||
|
y_values.imag = 0
|
||||||
|
elif actual_mode == 2:
|
||||||
|
y_values.real = 0
|
||||||
|
|
||||||
|
self.fun_kwargs['complex_mode'] = actual_mode
|
||||||
|
|
||||||
new_fit.set_data(x_values, y_values)
|
new_fit.set_data(x_values, y_values)
|
||||||
|
|
||||||
return new_fit
|
return new_fit
|
||||||
|
|
||||||
def sub(self, x_values):
|
def sub(self, x_values):
|
||||||
part_functions = []
|
part_functions = []
|
||||||
|
actual_mode = -1
|
||||||
|
if 'complex_mode' in self.fun_kwargs:
|
||||||
|
actual_mode = self.fun_kwargs['complex_mode']
|
||||||
|
self.fun_kwargs['complex_mode'] = 0
|
||||||
|
|
||||||
for sub_name, sub_y in zip(self.func.sub_name(), self.func.sub(self.p_final, x_values, **self.fun_kwargs)):
|
for sub_name, sub_y in zip(self.func.sub_name(), self.func.sub(self.p_final, x_values, **self.fun_kwargs)):
|
||||||
if np.iscomplexobj(sub_y):
|
if not actual_mode < 0:
|
||||||
|
if actual_mode == 1:
|
||||||
|
sub_y.imag = 0
|
||||||
|
elif actual_mode == 2:
|
||||||
|
sub_y.real = 0
|
||||||
|
|
||||||
part_functions.append(Signal(x_values, sub_y, name=sub_name))
|
part_functions.append(Signal(x_values, sub_y, name=sub_name))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
part_functions.append(Points(x_values, sub_y, name=sub_name))
|
part_functions.append(Points(x_values, sub_y, name=sub_name))
|
||||||
|
|
||||||
|
if actual_mode < 0:
|
||||||
|
self.fun_kwargs['complex_mode'] = actual_mode
|
||||||
|
|
||||||
return part_functions
|
return part_functions
|
||||||
|
Loading…
Reference in New Issue
Block a user