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

BUG, TST: fix-_check_ticks_props #34768

Merged
merged 7 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions pandas/tests/plotting/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def _check_ticks_props(

axes = self._flatten_visible(axes)
for ax in axes:
if xlabelsize or xrot:
if xlabelsize is not None or xrot is not None:
if isinstance(ax.xaxis.get_minor_formatter(), NullFormatter):
# If minor ticks has NullFormatter, rot / fontsize are not
# retained
Expand All @@ -286,7 +286,7 @@ def _check_ticks_props(
if xrot is not None:
tm.assert_almost_equal(label.get_rotation(), xrot)

if ylabelsize or yrot:
if ylabelsize is not None or yrot is not None:
if isinstance(ax.yaxis.get_minor_formatter(), NullFormatter):
labels = ax.get_yticklabels()
else:
Expand Down
24 changes: 24 additions & 0 deletions pandas/tests/plotting/test_common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pytest

import pandas.util._test_decorators as td

from pandas import DataFrame
from pandas.tests.plotting.common import TestPlotBase, _check_plot_works


@td.skip_if_no_mpl
class TestCommon(TestPlotBase):
def test__check_ticks_props(self):
# GH 34768
df = DataFrame({"b": [0, 1, 0], "a": [1, 2, 3]})
ax = _check_plot_works(df.plot, rot=30)
ax.yaxis.set_tick_params(rotation=30)
msg = "expected 0.00000 but got "
with pytest.raises(AssertionError, match=msg):
self._check_ticks_props(ax, xrot=0)
with pytest.raises(AssertionError, match=msg):
self._check_ticks_props(ax, xlabelsize=0)
with pytest.raises(AssertionError, match=msg):
self._check_ticks_props(ax, yrot=0)
with pytest.raises(AssertionError, match=msg):
self._check_ticks_props(ax, ylabelsize=0)
2 changes: 2 additions & 0 deletions pandas/tests/plotting/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def _assert_xtickslabels_visibility(self, axes, expected):
for ax, exp in zip(axes, expected):
self._check_visible(ax.get_xticklabels(), visible=exp)

@pytest.mark.xfail(reason="Waiting for PR 34334", strict=True)
@pytest.mark.slow
def test_plot(self):
from pandas.plotting._matplotlib.compat import _mpl_ge_3_1_0
Expand Down Expand Up @@ -467,6 +468,7 @@ def test_groupby_boxplot_sharex(self):
expected = [False, False, True, True]
self._assert_xtickslabels_visibility(axes, expected)

@pytest.mark.xfail(reason="Waiting for PR 34334", strict=True)
@pytest.mark.slow
def test_subplots_timeseries(self):
idx = date_range(start="2014-07-01", freq="M", periods=10)
Expand Down