forked from IPKM/nmreval
remove slot reference in parameter.get_state; fixes #125
This commit is contained in:
parent
902a35b71a
commit
2a69147ed4
@ -307,11 +307,25 @@ class Parameter:
|
|||||||
self.error = value * self.scale
|
self.error = value * self.scale
|
||||||
|
|
||||||
def get_state(self) -> dict:
|
def get_state(self) -> dict:
|
||||||
return {slot: getattr(self, slot) for slot in self.__slots__}
|
state_dict = {
|
||||||
|
'name': self.name,
|
||||||
|
'value': self._value,
|
||||||
|
'error': self.error,
|
||||||
|
'init_val': self.init_val,
|
||||||
|
'var': self.var,
|
||||||
|
'lb': self.lb,
|
||||||
|
'ub': self.ub,
|
||||||
|
'scale': self.scale,
|
||||||
|
'function': self.function,
|
||||||
|
'_expr': self._expr,
|
||||||
|
'_expr_disp': self._expr_disp,
|
||||||
|
'is_global': self.is_global,
|
||||||
|
}
|
||||||
|
return state_dict
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def set_state(state: dict) -> Parameter:
|
def set_state(state: dict) -> Parameter:
|
||||||
par = Parameter(state.pop('value'))
|
par = Parameter(state.get('name'), state.pop('value'))
|
||||||
for k, v in state.items():
|
for k, v in state.items():
|
||||||
setattr(par, k, v)
|
setattr(par, k, v)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user