Skip to content

Implement create_gif in QuickPlot - #1754

Merged
valentinsulzer merged 11 commits into
pybamm-team:developfrom
Saransh-cpp:implement-create_gif
Oct 25, 2021
Merged

Implement create_gif in QuickPlot#1754
valentinsulzer merged 11 commits into
pybamm-team:developfrom
Saransh-cpp:implement-create_gif

Conversation

@Saransh-cpp

Copy link
Copy Markdown
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
Copy Markdown
Member

Can you merge in develop?

Comment thread pybamm/batch_study.py
self.C_rates = C_rates
self.repeats = repeats
self.permutations = permutations
self.quick_plot = None

@Saransh-cpp Saransh-cpp Oct 21, 2021

Copy link
Copy Markdown
Member Author

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
Copy Markdown
Member Author

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

@codecov

codecov Bot commented Oct 21, 2021

Copy link
Copy Markdown

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.

Comment thread pybamm/batch_study.py
"""

if self.quick_plot is None:
self.quick_plot = pybamm.QuickPlot(self.sims)

Copy link
Copy Markdown
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

@TomTranter TomTranter left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread pybamm/plotting/quick_plot.py Outdated
):
input_solutions = solutions
solutions = []
self.solutions = []

Copy link
Copy Markdown
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
Copy Markdown
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!

@valentinsulzer
valentinsulzer merged commit ea4b565 into pybamm-team:develop Oct 25, 2021
@Saransh-cpp
Saransh-cpp deleted the implement-create_gif branch October 25, 2021 16:54
@d-cogswell d-cogswell mentioned this pull request Feb 10, 2025
8 tasks
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