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

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

Merged
merged 4 commits into from
Feb 27, 2017
Merged
Show file tree
Hide file tree
Changes from 2 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))
df.plot.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
8 changes: 8 additions & 0 deletions pandas/util/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,14 @@ def _skip_if_mpl_1_5():
pytest.skip("matplotlib 1.5")


def _skip_if_mpl_1():
import matplotlib
Copy link
Contributor

@jreback jreback Feb 27, 2017

Choose a reason for hiding this comment

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

actually you don't need this, instead use:

if self.mpl_ge_2_0_0:

as these are defined in the base class (you can look in pandas.tools.plotting

Copy link
Contributor Author

@ResidentMario ResidentMario Feb 27, 2017

Choose a reason for hiding this comment

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

self.mpl_get_2_0_0 I assume? Edit: nvm, I see it is indeed ge. What does that stand for?

Copy link
Contributor

Choose a reason for hiding this comment

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

no take this function out

v = matplotlib.__version__
if v < LooseVersion('2.0.0') or v[0] == '0' or v[0] == '1':
import pytest
pytest.skip("matplotlib 1.5")
Copy link
Contributor

Choose a reason for hiding this comment

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

matpotlib < 2.0.0



def _skip_if_no_scipy():
try:
import scipy.stats # noqa
Expand Down