- Scenario: saving a CMF as pickle file and trying to use its
__repr__.
- Issue: Missing properties
- Assumed source point of failure: CMF implements
__getstate__ with matrices only and subclasses don't override.
- Proposed solution:
- Remove usage of the
__getstate__
- Instead of using properties which shouldn't be saved in pickle, use
@cached_property.
- Override
@cached_property such that cached properties will not be saved in pickle.
i.e. something like this maybe :)
def cached_property(func, ignore_pickle=True):
prop = functools.cached_property(func)
prop._ignore_pickle = ignore_pickle
return prop
__repr__.__getstate__with matrices only and subclasses don't override.__getstate__@cached_property.@cached_propertysuch that cached properties will not be saved in pickle.i.e. something like this maybe :)