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

Raise error if empty list passed to QuickPlot #3172

Closed
rtimms opened this issue Jul 20, 2023 · 1 comment · Fixed by #3359
Closed

Raise error if empty list passed to QuickPlot #3172

rtimms opened this issue Jul 20, 2023 · 1 comment · Fixed by #3359
Labels
difficulty: easy A good issue for someone new. Can be done in a few hours priority: low No existing plans to resolve

Comments

@rtimms
Copy link
Contributor

rtimms commented Jul 20, 2023

If you pass any empty list to QuickPlot you get the error:

  File "/Users/robertwtimms/Documents/PyBaMM/test.py", line 3, in <module>
    pybamm.QuickPlot([])
  File "/Users/robertwtimms/Documents/PyBaMM/pybamm/plotting/quick_plot.py", line 146, in __init__
    output_variables = models[0].default_quick_plot_variables
IndexError: list index out of range

It would be nicer to catch this with a more informative error earlier so you can check if you've made a silly mistake like I did where I wasn't appending solutions to a list.

Code to reproduce:

import pybamm

pybamm.QuickPlot([])
@rtimms rtimms added difficulty: easy A good issue for someone new. Can be done in a few hours priority: low No existing plans to resolve labels Jul 20, 2023
@valentinsulzer
Copy link
Member

Also it should work if a single variable is passed in as the plotting variable instead of a list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: easy A good issue for someone new. Can be done in a few hours priority: low No existing plans to resolve
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants