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

#1051 fix 2D plot bug #1055

Merged
merged 2 commits into from
Jun 16, 2020
Merged

#1051 fix 2D plot bug #1055

merged 2 commits into from
Jun 16, 2020

Conversation

rtimms
Copy link
Contributor

@rtimms rtimms commented Jun 14, 2020

Description

Fixes a bug where 2D variables that depend on y and z are transposed in QuickPlot.

This was introduced in PR #1020 where the way 2D (y,z) variables are processed was changed, and I missed updating in quickplot as the scripts I had been using for 2+1D models all did the plotting manually... sorry!

Fixes #1051

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

@codecov
Copy link

codecov bot commented Jun 14, 2020

Codecov Report

Merging #1055 into develop will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #1055   +/-   ##
========================================
  Coverage    97.63%   97.63%           
========================================
  Files          237      237           
  Lines        12371    12386   +15     
========================================
+ Hits         12078    12093   +15     
  Misses         293      293           
Impacted Files Coverage Δ
pybamm/plotting/quick_plot.py 100.00% <100.00%> (ø)

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 06237e9...76a64d6. Read the comment docs.

Copy link
Member

@brosaplanella brosaplanella left a comment

Choose a reason for hiding this comment

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

Look good, thanks Rob! However, I am not sure why codecov fails. Is it something to do with this PR or is it more general?

@rtimms
Copy link
Contributor Author

rtimms commented Jun 14, 2020

the percentage coverage on the difference is too low. I can add a test to catch it

@brosaplanella
Copy link
Member

But quickplot is already tested, right? If so, then it is fine by me :)

@valentinsulzer
Copy link
Member

Yeah please add more tests for quickplot as it's easy to break things without realising atm

@rtimms
Copy link
Contributor Author

rtimms commented Jun 15, 2020

I've added some more tests to ensure the variables/plot data in quick plot get updated properly for different time units (and therefore tests shape, transposed vs not, etc.). For 1D plots you can get this info from the Lines2D object that gets stored in self.plots[key]. The 2D plots (contourf) create a QuadContourSet object which doesn't store the z data as an attribute, so I've just stored the z_data directly in self.plots[key][0][1] and the QuadContourSet object in self.plots[key][0][0] (since you cant plot 2D vars with multiple solutions, you never actually use that final list, so we can just use it to store the object then the data -- if I have understood what the list contains correctly)

also, python was complaining about the number of open figures when running the quick plot tests, so I added a method pybamm.close_plots that just closes all the plots

Copy link
Member

@brosaplanella brosaplanella left a comment

Choose a reason for hiding this comment

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

The new tests look great, thanks Rob!

Copy link
Member

@valentinsulzer valentinsulzer left a comment

Choose a reason for hiding this comment

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

Thanks, tests look good!

@rtimms rtimms merged commit 16064d8 into develop Jun 16, 2020
@rtimms rtimms deleted the issue-1051-2D-plot-bug branch June 16, 2020 07:34
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.

plotting of 2D current collector variables
3 participants