Skip to content

Commit

Permalink
BUG, TST: fix-_check_ticks_props (pandas-dev#34768)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli authored Jun 16, 2020
1 parent f34fd58 commit df6f668
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
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

0 comments on commit df6f668

Please sign in to comment.