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