From d7657bf1da594a5b896d1734a816f97f5d9c7607 Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Sun, 14 Jun 2020 15:00:45 +0100 Subject: [PATCH 1/7] fix-_check_ticks_props --- pandas/tests/plotting/common.py | 4 ++-- pandas/tests/plotting/test_frame.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pandas/tests/plotting/common.py b/pandas/tests/plotting/common.py index f2f7b37170ec9..896d3278cdde1 100644 --- a/pandas/tests/plotting/common.py +++ b/pandas/tests/plotting/common.py @@ -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 @@ -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: diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index c84a09f21f46b..6d74d231aeac6 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -3350,6 +3350,19 @@ def test_colors_of_columns_with_same_name(self): for legend, line in zip(result.get_legend().legendHandles, result.lines): assert legend.get_color() == line.get_color() + def test_plot_with_rot(self): + df = pd.DataFrame({"b": [0, 1, 0], "a": [1, 2, 3]}) + ax = _check_plot_works(df.plot, rot=30) + ax.yaxis.set_tick_params(rotation=30) + with pytest.raises(AssertionError): + self._check_ticks_props(ax, xrot=0) + with pytest.raises(AssertionError): + self._check_ticks_props(ax, xlabelsize=0) + with pytest.raises(AssertionError): + self._check_ticks_props(ax, yrot=0) + with pytest.raises(AssertionError): + self._check_ticks_props(ax, ylabelsize=0) + def _generate_4_axes_via_gridspec(): import matplotlib.pyplot as plt From 642da78ad5658ed7621fec50364de80dbcf73e48 Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Sun, 14 Jun 2020 15:03:18 +0100 Subject: [PATCH 2/7] pr number --- pandas/tests/plotting/test_frame.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index 6d74d231aeac6..1fb9e644d082e 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -3351,6 +3351,7 @@ def test_colors_of_columns_with_same_name(self): assert legend.get_color() == line.get_color() def test_plot_with_rot(self): + # GH 34768 df = pd.DataFrame({"b": [0, 1, 0], "a": [1, 2, 3]}) ax = _check_plot_works(df.plot, rot=30) ax.yaxis.set_tick_params(rotation=30) From 24200db4efecf3cd68b2edd15f1c3265fb093a2f Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Sun, 14 Jun 2020 15:10:29 +0100 Subject: [PATCH 3/7] catch message --- pandas/tests/plotting/test_frame.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index 1fb9e644d082e..faa11a2e79f5a 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -3355,13 +3355,14 @@ def test_plot_with_rot(self): df = pd.DataFrame({"b": [0, 1, 0], "a": [1, 2, 3]}) ax = _check_plot_works(df.plot, rot=30) ax.yaxis.set_tick_params(rotation=30) - with pytest.raises(AssertionError): + msg = "expected 0.00000 but got " + with pytest.raises(AssertionError, match=msg): self._check_ticks_props(ax, xrot=0) - with pytest.raises(AssertionError): + with pytest.raises(AssertionError, match=msg): self._check_ticks_props(ax, xlabelsize=0) - with pytest.raises(AssertionError): + with pytest.raises(AssertionError, match=msg): self._check_ticks_props(ax, yrot=0) - with pytest.raises(AssertionError): + with pytest.raises(AssertionError, match=msg): self._check_ticks_props(ax, ylabelsize=0) From f711ff4fa4e5dd7853e00bcdac9b767d2a279afe Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Sun, 14 Jun 2020 17:38:05 +0100 Subject: [PATCH 4/7] xfail tests which shouldn't be passing --- pandas/tests/plotting/test_frame.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index faa11a2e79f5a..2eb67fe656903 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -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") @pytest.mark.slow def test_plot(self): from pandas.plotting._matplotlib.compat import _mpl_ge_3_1_0 @@ -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") @pytest.mark.slow def test_subplots_timeseries(self): idx = date_range(start="2014-07-01", freq="M", periods=10) From 579fc3816504615433693296bb7bb66b28b1e818 Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Mon, 15 Jun 2020 11:34:34 +0100 Subject: [PATCH 5/7] Update pandas/tests/plotting/test_frame.py --- pandas/tests/plotting/test_frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index 2eb67fe656903..516c14b2db4e8 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -3352,7 +3352,7 @@ def test_colors_of_columns_with_same_name(self): for legend, line in zip(result.get_legend().legendHandles, result.lines): assert legend.get_color() == line.get_color() - def test_plot_with_rot(self): + def test__check_ticks_props(self): # GH 34768 df = pd.DataFrame({"b": [0, 1, 0], "a": [1, 2, 3]}) ax = _check_plot_works(df.plot, rot=30) From 02c9d49b46cee157688f1a39caa997ebed9477cb Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Mon, 15 Jun 2020 21:28:38 +0100 Subject: [PATCH 6/7] move test --- pandas/tests/plotting/test_common.py | 24 ++++++++++++++++++++++++ pandas/tests/plotting/test_frame.py | 15 --------------- 2 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 pandas/tests/plotting/test_common.py diff --git a/pandas/tests/plotting/test_common.py b/pandas/tests/plotting/test_common.py new file mode 100644 index 0000000000000..af67ed7ec215b --- /dev/null +++ b/pandas/tests/plotting/test_common.py @@ -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) diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index 516c14b2db4e8..de450661ad783 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -3352,21 +3352,6 @@ def test_colors_of_columns_with_same_name(self): for legend, line in zip(result.get_legend().legendHandles, result.lines): assert legend.get_color() == line.get_color() - def test__check_ticks_props(self): - # GH 34768 - df = pd.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) - def _generate_4_axes_via_gridspec(): import matplotlib.pyplot as plt From 0497a26cc62f7a9e42f024f086170ffe7ed7dfad Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Tue, 16 Jun 2020 07:50:42 +0100 Subject: [PATCH 7/7] strict xfail --- pandas/tests/plotting/test_frame.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index de450661ad783..fb8f62c946caf 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -48,7 +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") + @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 @@ -468,7 +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") + @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)