Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simulation save and load #732

Merged
merged 8 commits into from
Nov 15, 2019
Merged

Conversation

valentinsulzer
Copy link
Member

@valentinsulzer valentinsulzer commented Nov 13, 2019

Description

Sort out all pickle issues and add very basic save / load functionality.

Generated python code cannot be pickled so raises error (@martinjrobins any ideas for a way round this?)

Note this branch currently has changes from 731 but 731 is ready be merged to master

Fixes #730

Type of change

Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s.

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist:

  • No style issues: $ flake8
  • All tests pass: $ python run-tests.py --unit
  • The documentation builds: $ cd docs and then $ make clean; make html

You can run all three at once, using $ python run-tests.py --quick.

Further checks:

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@valentinsulzer valentinsulzer changed the title Add model save and load Add simulation save and load Nov 13, 2019
@codecov
Copy link

codecov bot commented Nov 14, 2019

Codecov Report

Merging #732 into master will increase coverage by 0.09%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #732      +/-   ##
==========================================
+ Coverage   98.18%   98.27%   +0.09%     
==========================================
  Files         175      175              
  Lines        9288     9350      +62     
==========================================
+ Hits         9119     9189      +70     
+ Misses        169      161       -8
Impacted Files Coverage Δ
pybamm/expression_tree/binary_operators.py 98.84% <100%> (ø) ⬆️
pybamm/solvers/dae_solver.py 99.52% <100%> (+0.07%) ⬆️
pybamm/solvers/ode_solver.py 97.27% <100%> (+0.27%) ⬆️
pybamm/solvers/casadi_solver.py 98.79% <100%> (+0.09%) ⬆️
pybamm/simulation.py 85.61% <100%> (+1.05%) ⬆️
pybamm/parameters/parameter_values.py 100% <100%> (ø) ⬆️
pybamm/discretisations/discretisation.py 99.71% <100%> (-0.01%) ⬇️
pybamm/models/base_model.py 98.51% <100%> (+0.66%) ⬆️
pybamm/expression_tree/operations/evaluate.py 94.68% <0%> (+3.19%) ⬆️
pybamm/solvers/idaklu_solver.py 87.25% <0%> (+3.92%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eff7d0a...4730e80. Read the comment docs.

@martinjrobins
Copy link
Contributor

at some point the generated python code is just a plain string, I would pickle that instead. You would have to ensure that when you load the pickled object that the string is then converted to python bytecode again

@valentinsulzer valentinsulzer changed the base branch from master to 2plus1D-models November 14, 2019 13:38
@valentinsulzer valentinsulzer changed the base branch from 2plus1D-models to master November 14, 2019 13:38
Copy link
Contributor

@rtimms rtimms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great thanks @tinosulzer

@valentinsulzer
Copy link
Member Author

at some point the generated python code is just a plain string, I would pickle that instead. You would have to ensure that when you load the pickled object that the string is then converted to python bytecode again

Given that the default setup is now casadi I will leave this up to a new issue

@valentinsulzer valentinsulzer merged commit 68bcec7 into master Nov 15, 2019
@valentinsulzer valentinsulzer deleted the issue-730-pickle-module branch November 15, 2019 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pickling parameter module
3 participants