Skip to content

Loading and saving features (and memoization) #124

Description

@Jfeatherstone

See #123, where the discussion began.

The goal of this feature is to reduce the number of times you need to repeat a costly calculation (primarily the Fit.find_xmin() call, but others too) by having robust systems to save and load Fit objects to and from the filesystem.

Proposed solution:

  • While we currently have functionality to pickle these objects, it would be better to have a more tailored solution for the specific objects. One issue I can imagine arising just by pickling is if you update your version of powerlaw, the calculation methods might have changed but you would still be using the old cached results. It would be good to do some version checking when saving and loading. Further, while pickling is convenient, it is of course a Python-specific encoding; I think it would be good to put a little more effort into these save/load functions to parse a more generic filetype. I would propose using the hdf5 format, since it would allow us to include important metatadata, and is becoming more and more standard.
  • Per @EliasL's comments, we could add the option (disabled by default) to automatically save Fit objects in a specified directory, and try to read them in place of recalculating something where possible. This would save the user from having to explicitly call the saving or loading functions, at the cost of potentially making a project directory a little messier.

I will start working on these changes soon! If other users/maintainers have comments or suggestions, please let me know.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions