Skip to content

Pickling of CMF subclasses #144

@UriKH

Description

@UriKH
  • 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:
  1. Remove usage of the __getstate__
  2. Instead of using properties which shouldn't be saved in pickle, use @cached_property.
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions