Skip to content

Modifies QuickPlot.plot to take a list of times and show superimposed plots in case of 1D variables.#4529

Merged
kratman merged 15 commits into
pybamm-team:developfrom
medha-14:quickplot_plot
Nov 22, 2024
Merged

Modifies QuickPlot.plot to take a list of times and show superimposed plots in case of 1D variables.#4529
kratman merged 15 commits into
pybamm-team:developfrom
medha-14:quickplot_plot

Conversation

@medha-14
Copy link
Copy Markdown
Contributor

@medha-14 medha-14 commented Oct 20, 2024

Description

Fixes #4271
Related to #3164

model = pybamm.lithium_ion.DFN()
sim = pybamm.Simulation(model)
sim.solve([0, 3600])
plot = QuickPlot(sim)
plot.plot([0.5,0.6,0.8])

image

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: $ pre-commit run (or $ nox -s pre-commit) (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)
  • All tests pass: $ python run-tests.py --all (or $ nox -s tests)
  • The documentation builds: $ python run-tests.py --doctest (or $ nox -s doctests)

You can run integration tests, unit tests, and doctests together at once, using $ python run-tests.py --quick (or $ nox -s quick).

Further checks:

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

@medha-14
Copy link
Copy Markdown
Contributor Author

I will be working on adding different colors and a legend to the time plots to make them easier to differentiate. Please let me know if you have any suggestions for changes or improvements.

@medha-14
Copy link
Copy Markdown
Contributor Author

I've added different colors to the time plots to make them easier to differentiate. Additionally, I've fixed some of the failing tests. Please suggest any changes or improvements.

image

Copy link
Copy Markdown
Member

@arjxn-py arjxn-py left a comment

Choose a reason for hiding this comment

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

Awesome work @medha-14, you might just want to look into the keyerror that's being raised.
You can try debugging that by running one test at a time something like - pytest tests/unit/test_plotting/test_quick_plot.py::test_plot_1plus1D_spme Otherwise this looks really good.

arjxn-py

This comment was marked as duplicate.

Comment thread src/pybamm/plotting/quick_plot.py Outdated
Comment thread src/pybamm/plotting/quick_plot.py Outdated
Comment thread tests/unit/test_plotting/test_quick_plot.py Outdated
@medha-14
Copy link
Copy Markdown
Contributor Author

I will work on fixing the failing tests. Should I also start working on adding new tests for this method?

@kratman
Copy link
Copy Markdown
Contributor

kratman commented Oct 23, 2024

I will work on fixing the failing tests. Should I also start working on adding new tests for this method?

@medha-14 Coverage reports will only start appearing for this PR after tests pass. You will need to make sure all new code is covered by tests as well as fixing the existing tests

@medha-14
Copy link
Copy Markdown
Contributor Author

I have fixed the failing tests and tried to add tests , using a list of time in the plot function. I am open to work on any suggested improvements.

@medha-14 medha-14 requested review from arjxn-py and kratman October 28, 2024 09:02
@medha-14
Copy link
Copy Markdown
Contributor Author

medha-14 commented Nov 2, 2024

Hi @kratman, could you review this and let me know what further changes I should make?

@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.22%. Comparing base (204c076) to head (4bea86c).
Report is 166 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4529      +/-   ##
===========================================
- Coverage    99.25%   99.22%   -0.04%     
===========================================
  Files          302      302              
  Lines        22838    22821      -17     
===========================================
- Hits         22667    22643      -24     
- Misses         171      178       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@medha-14
Copy link
Copy Markdown
Contributor Author

Are there any other changes or improvements that I could make to further enhance the implementation?

@kratman
Copy link
Copy Markdown
Contributor

kratman commented Nov 21, 2024

@medha-14 Sorry for the delay on this one, I will start reviewing this again

Copy link
Copy Markdown
Contributor

@kratman kratman left a comment

Choose a reason for hiding this comment

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

Small findings, I will do a full review another day

Comment thread src/pybamm/plotting/quick_plot.py Outdated
Comment thread src/pybamm/plotting/quick_plot.py Outdated
Comment thread src/pybamm/plotting/quick_plot.py Outdated
@kratman
Copy link
Copy Markdown
Contributor

kratman commented Nov 21, 2024

Please also add a change log entry. Note that we are doing a release, so once #4598 is merged, there will likely be a merge conflict in the changelog

Copy link
Copy Markdown
Contributor

@kratman kratman left a comment

Choose a reason for hiding this comment

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

This should be the last round of findings. Once these are resolved I will approve. Please double check that the figures still appear as you originally intended. Just good to do a visual double check. I will review those as well

Comment thread CHANGELOG.md Outdated
Comment thread src/pybamm/plotting/quick_plot.py Outdated
Comment thread src/pybamm/plotting/quick_plot.py Outdated
Comment thread src/pybamm/plotting/quick_plot.py
Copy link
Copy Markdown
Member

@agriyakhetarpal agriyakhetarpal left a comment

Choose a reason for hiding this comment

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

Thanks, @medha-14! I only skimmed through the changes and haven't been involved in the review here, I'll request a review from Eric for the final merge.

Comment thread CHANGELOG.md Outdated
Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@kratman kratman left a comment

Choose a reason for hiding this comment

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

Thanks looks good

@kratman
Copy link
Copy Markdown
Contributor

kratman commented Nov 22, 2024

@allcontributors add @medha-14 for code

@allcontributors
Copy link
Copy Markdown
Contributor

@kratman

@medha-14 already contributed before to code

@kratman
Copy link
Copy Markdown
Contributor

kratman commented Nov 22, 2024

I will merge once I see the windows 3.9 check pass. I do not expect a problem, so this should be merged in a couple minutes

@kratman kratman merged commit eefa374 into pybamm-team:develop Nov 22, 2024
@medha-14
Copy link
Copy Markdown
Contributor Author

Thanks a lot everyone!

@medha-14 medha-14 deleted the quickplot_plot branch November 22, 2024 16:15
kratman added a commit that referenced this pull request Nov 27, 2024
* Revert "Modifies `QuickPlot.plot` to take a list of times and show superimposed plots in case of 1D variables. (#4529)"

This reverts commit b50d4a9.

* style: pre-commit fixes

* Fix changelog with PR number

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
kratman added a commit that referenced this pull request Nov 27, 2024
* Revert "Modifies `QuickPlot.plot` to take a list of times and show superimposed plots in case of 1D variables. (#4529)"

This reverts commit b50d4a9.

* style: pre-commit fixes

* Fix changelog with PR number

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@kratman kratman mentioned this pull request Nov 27, 2024
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.

Allow QuickPlot.plot to take a list of times

4 participants