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

Implement create_gif in QuickPlot #1754

Merged
merged 11 commits into from
Oct 25, 2021

Conversation

Saransh-cpp
Copy link
Member

Description

  • Added a new method to create GIFs in QuickPlot
  • Added wrapper functions in pybamm.Simulation and pybamm.BatchStudy
  • A new dependency - imageio

Fixes #1752

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. If necessary, also add to the list of breaking changes.

  • 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

@Saransh-cpp Saransh-cpp marked this pull request as draft October 21, 2021 13:33
@valentinsulzer
Copy link
Member

Can you merge in develop?

@@ -85,6 +85,7 @@ def __init__(
self.C_rates = C_rates
self.repeats = repeats
self.permutations = permutations
self.quick_plot = None
Copy link
Member Author

@Saransh-cpp Saransh-cpp Oct 21, 2021

Choose a reason for hiding this comment

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

Not sure if this is the best way to implement this but I had to check if an object of QuickPlot has been created by the user (for calling the QuickPlot.create_gif method, same for the Simulation class)

@Saransh-cpp
Copy link
Member Author

Also I think I messed something up while resolving conflicts, I'll check locally

@codecov
Copy link

codecov bot commented Oct 21, 2021

Codecov Report

Merging #1754 (af7600c) into develop (4ece786) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #1754   +/-   ##
========================================
  Coverage    99.28%   99.28%           
========================================
  Files          343      343           
  Lines        18868    18894   +26     
========================================
+ Hits         18733    18759   +26     
  Misses         135      135           
Impacted Files Coverage Δ
pybamm/batch_study.py 100.00% <100.00%> (ø)
pybamm/plotting/quick_plot.py 99.72% <100.00%> (+0.01%) ⬆️
pybamm/simulation.py 98.03% <100.00%> (+0.02%) ⬆️

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 4ece786...af7600c. Read the comment docs.

"""

if self.quick_plot is None:
self.quick_plot = pybamm.QuickPlot(self.sims)
Copy link
Member Author

Choose a reason for hiding this comment

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

I thought of 3 options here (when the user hasn't called the plot method) -

  • raise an error
  • pass in kwargs maybe, and then create a QuickPlot object (didn't try)
  • create a QuickPlot object with default parameters (current implementation)

(same for the Simulation class)

@Saransh-cpp Saransh-cpp marked this pull request as ready for review October 21, 2021 15:59
Copy link
Contributor

@TomTranter TomTranter left a comment

Choose a reason for hiding this comment

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

Looks good to me thanks

@@ -103,7 +104,7 @@ def __init__(
variable_limits="fixed",
):
input_solutions = solutions
solutions = []
self.solutions = []
Copy link
Contributor

Choose a reason for hiding this comment

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

how come you need to store solutions as an attribute now?

Copy link
Member Author

Choose a reason for hiding this comment

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

My bad, I don't really remember why I did this 😅. Thanks!

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.

Could we move the create_gif function from BattBot to be a method of QuickPlot
4 participants