Skip to content

TST: DataFrame.hist() does not get along with matplotlib.pyplot.tight_layout() #15515

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 4 commits into from
Feb 27, 2017
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pandas/tests/plotting/test_hist_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,16 @@ def test_hist_layout(self):
with tm.assertRaises(ValueError):
df.hist(layout=(-1, -1))

@slow
# GH 9351
def test_tight_layout(self):
if self.mpl_ge_2_0_0:
df = DataFrame(randn(100, 2))
_check_plot_works(df.hist)
self.plt.tight_layout()
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need the try/except (if it works it won't raise)

add a 1-line comment & the issue number as a comment

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you need a _check_plot_works here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would _check_plot_works(df.hist); self.plt.tight_layout() work? The method seems to be designed for testing parameter inputs, but tight_layout isn't a histogram parameter.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes that's fine. I realize this just raises AttributeError, so that would be caught by the tests anyhow.


tm.close()


@tm.mplskip
class TestDataFrameGroupByPlots(TestPlotBase):
Expand Down