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

Add warning for multiple pyplot.figure calls with same ID #27992

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Impaler343
Copy link
Contributor

@Impaler343 Impaler343 commented Mar 29, 2024

PR summary

Closes #27978. This hopefully adds the relevant warning discussed in the issue

PR checklist

def test_multiple_same_figure_calls():
with pytest.warns(UserWarning, match="Ignoring specified arguments in this call"):
fig = mpl.pyplot.figure(1, figsize=(1, 2))
fig = mpl.pyplot.figure(1, figsize=(3, 4))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fig = mpl.pyplot.figure(1, figsize=(3, 4))
fig2 = mpl.pyplot.figure(1, figsize=(3, 4))
assert fig2 is fig
fig3 = mpl.pyplot.figure(1)
assert fig3 is fig

Do we have a test that it does not warn when re-accessed without parameters else where? It can not hurt to test here too even if we do.

Copy link
Member

Choose a reason for hiding this comment

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

and it might be better to move the first fig invocation out of the context manager? 50/50 on that though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: strange behaviour when redefining figure size
3 participants