Skip to content

Commit df6f668

Browse files
authored
BUG, TST: fix-_check_ticks_props (pandas-dev#34768)
1 parent f34fd58 commit df6f668

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

pandas/tests/plotting/common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def _check_ticks_props(
272272

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

289-
if ylabelsize or yrot:
289+
if ylabelsize is not None or yrot is not None:
290290
if isinstance(ax.yaxis.get_minor_formatter(), NullFormatter):
291291
labels = ax.get_yticklabels()
292292
else:

pandas/tests/plotting/test_common.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import pytest
2+
3+
import pandas.util._test_decorators as td
4+
5+
from pandas import DataFrame
6+
from pandas.tests.plotting.common import TestPlotBase, _check_plot_works
7+
8+
9+
@td.skip_if_no_mpl
10+
class TestCommon(TestPlotBase):
11+
def test__check_ticks_props(self):
12+
# GH 34768
13+
df = DataFrame({"b": [0, 1, 0], "a": [1, 2, 3]})
14+
ax = _check_plot_works(df.plot, rot=30)
15+
ax.yaxis.set_tick_params(rotation=30)
16+
msg = "expected 0.00000 but got "
17+
with pytest.raises(AssertionError, match=msg):
18+
self._check_ticks_props(ax, xrot=0)
19+
with pytest.raises(AssertionError, match=msg):
20+
self._check_ticks_props(ax, xlabelsize=0)
21+
with pytest.raises(AssertionError, match=msg):
22+
self._check_ticks_props(ax, yrot=0)
23+
with pytest.raises(AssertionError, match=msg):
24+
self._check_ticks_props(ax, ylabelsize=0)

pandas/tests/plotting/test_frame.py

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def _assert_xtickslabels_visibility(self, axes, expected):
4848
for ax, exp in zip(axes, expected):
4949
self._check_visible(ax.get_xticklabels(), visible=exp)
5050

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

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

0 commit comments

Comments
 (0)