Skip to content

Add figure tests for plotting functions #4885

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

Open
medha-14 opened this issue Mar 1, 2025 · 3 comments · May be fixed by #4980
Open

Add figure tests for plotting functions #4885

medha-14 opened this issue Mar 1, 2025 · 3 comments · May be fixed by #4980
Assignees
Labels
difficulty: medium Will take a few days plotting Related to pybamm.QuickPlot and surrounding functionality

Comments

@medha-14
Copy link
Contributor

medha-14 commented Mar 1, 2025

Currently, PyBaMM lacks automated figure tests to verify the correctness of plots generated by QuickPlot or other plotting functions. This can lead to unintended changes in the plots and make it difficult to verify whether modifications to these functions are correctly implemented. Adding figure-based tests using
pytest-mpl or a similar approach will help detect unintended changes in plot outputs.

@medha-14
Copy link
Contributor Author

medha-14 commented Mar 1, 2025

I would be happy to work on this if we decide to go ahead with it :)

@agriyakhetarpal
Copy link
Member

Sounds good to me – thanks for opening this issue publicly following our discussion, @medha-14! I cannot comment on how how long it can take or how a framework for this can be set up, as you are more familiar with it. I can only say that this is very cool, and I would be open to a PoC PR, after which we can decide whether we want to keep it.

The decision would likely be based on the implementation, i.e. how the code is written, and on the ease of maintenance:

  • how easy it will be to debug failing image comparisons
    • how do failures show up in the tests
    • are there hints on why they fail
  • is there a chance they will fail often, i.e., will they be flaky, etc.
  • what parts of the plotting functionality are tested

If you have answers to these questions or are working on assembling them, please feel free to comment them below whenever you do (or in the PR thread as you wish).

Linking the SunPy implementation and relevant references here:

@agriyakhetarpal agriyakhetarpal added difficulty: medium Will take a few days plotting Related to pybamm.QuickPlot and surrounding functionality labels Mar 1, 2025
@medha-14
Copy link
Contributor Author

medha-14 commented Mar 5, 2025

I am currently working on this and will be setting up a PoC PR in a few days time, which will be focused on evaluating how well this feature handles image comparisons, debugging failures, and also how easy it will be to maintain. I'll share my findings and would love to get feedback along the way.

@medha-14 medha-14 linked a pull request Apr 17, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: medium Will take a few days plotting Related to pybamm.QuickPlot and surrounding functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants