to_base() in serializable.py module possibly unnecessary
All subclasses of FWSerializable
defined in serializable.py
have the method to_base()
but the base class FWSerializable
has no such method. The method is applied in get_basetyped()
to all instances of class FWSerializable
, possibly not defined in the serializable.py
module and that may not have the to_base()
method.
- Try to find out whether
get_basetyped()
is really necessary and eliminate it together withto_base()
if possible. - If
get_basetyped()
is really needed then we have to subclassFWSerializable
and only then use the specific subclass (with this method) to derive all the other subclasses in the module.
In addition the function get_serializable()
should be used more - if possible in all to_dict()
methods. With this function it is possible to process all dict keys in a loop. For example
return {'_fw_name': self._fw_name, 'names': self.names,
'calc': FWCalculator.from_base(self.calc),
'struct': FWAMMLStructure.from_base(self.struct),
'constr': get_serializable(self.constr),
'results': FWDataFrame(self.results)}
will become:
keys = ['_fw_name', 'names', 'calc', 'struct', 'constr', 'results']
return {k: get_serializable(getattr(self, k)) for k in keys}
Edited by Ivan Kondov