deal with missing weight key get_state and set_state; partly fixes #158
This commit is contained in:
parent
8a6c909c3e
commit
7c71061877
@ -393,8 +393,7 @@ class FitResult(Points):
|
|||||||
def get_state(self):
|
def get_state(self):
|
||||||
state = super().get_state()
|
state = super().get_state()
|
||||||
|
|
||||||
for attr in ['idx', 'fun_kwargs', 'nobs', 'nvar',
|
for attr in ['idx', 'fun_kwargs', 'nobs', 'nvar', 'we', 'islog', 'iscomplex', 'x_data', 'y_data']:
|
||||||
'islog', 'iscomplex', 'x_data', 'y_data']:
|
|
||||||
state[attr] = getattr(self, attr)
|
state[attr] = getattr(self, attr)
|
||||||
|
|
||||||
state['name'] = self._model_name
|
state['name'] = self._model_name
|
||||||
@ -412,6 +411,8 @@ class FitResult(Points):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def set_state(state, **kwargs):
|
def set_state(state, **kwargs):
|
||||||
state['params'] = {k: Parameter.set_state(v) for k, v in state.pop('params').items()}
|
state['params'] = {k: Parameter.set_state(v) for k, v in state.pop('params').items()}
|
||||||
|
if 'we' not in state:
|
||||||
|
state['we'] = '?'
|
||||||
data = FitResult(**state)
|
data = FitResult(**state)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
@ -440,6 +441,9 @@ class FitResult(Points):
|
|||||||
return new_fit
|
return new_fit
|
||||||
|
|
||||||
def sub(self, x_values):
|
def sub(self, x_values):
|
||||||
|
if self.func is None:
|
||||||
|
raise ValueError('no fit function available to calculate new y values')
|
||||||
|
|
||||||
part_functions = []
|
part_functions = []
|
||||||
actual_mode = -1
|
actual_mode = -1
|
||||||
if 'complex_mode' in self.fun_kwargs:
|
if 'complex_mode' in self.fun_kwargs:
|
||||||
|
Loading…
Reference in New Issue
Block a user