Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use fig, ax = plt.subplots() in tests #18553

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

Merged
merged 1 commit into from
Sep 24, 2020

Conversation

timhoffm
Copy link
Member

PR Summary

Use

fig, ax = plt.subplots()

instead of

fig = plt.figure()
ax = plt.subplots(1, 1, 1)

The latter was a common pattern in tests. The former is shorter and thus adds less clutter to the tests.

More similar patterns could be replaced, but that's for another time.

Also fixed here along the way:

  • One test that used plt.errorbar instead of ax.errorbar - we should test using the OOP API unless we want to test pyplot specifically.
  • Some copy-paste errors in comments.

@timhoffm timhoffm added this to the v3.4.0 milestone Sep 24, 2020
Copy link
Member

@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

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

I am hesitant to make too many changes to the tests (as we don't have tests on the tests) in general, but not hesitant enough to reject this change.

@QuLogic
Copy link
Member

QuLogic commented Sep 24, 2020

Travis passed, even though it is 'waiting' twice.

@QuLogic QuLogic merged commit 34f99a9 into matplotlib:master Sep 24, 2020
@timhoffm
Copy link
Member Author

I am hesitant to make too many changes to the tests (as we don't have tests on the tests) in general.

That's fair. OTOH test code should be concise. And it may serve as a reference for users, which is why we should not use outdated or uncommon ideoms there. IMHO a careful cleanup is advisable.

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.

4 participants