From cdc136383b441a5af4f00540f427fefe02288f45 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Fri, 23 Sep 2022 16:51:17 -0700 Subject: [PATCH 1/2] WARN: Catch warning in tests --- pandas/tests/plotting/frame/test_frame_color.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pandas/tests/plotting/frame/test_frame_color.py b/pandas/tests/plotting/frame/test_frame_color.py index e384861d8a57c..28232e9d0f007 100644 --- a/pandas/tests/plotting/frame/test_frame_color.py +++ b/pandas/tests/plotting/frame/test_frame_color.py @@ -15,6 +15,8 @@ _check_plot_works, ) +from pandas.plotting._matplotlib.compat import mpl_ge_3_6_0 + @td.skip_if_no_mpl class TestDataFrameColor(TestPlotBase): @@ -204,7 +206,11 @@ def test_scatter_with_c_column_name_with_colors(self, cmap, kw): columns=["length", "width"], ) df["species"] = ["r", "r", "g", "g", "b"] - ax = df.plot.scatter(x=0, y=1, cmap=cmap, **{kw: "species"}) + if mpl_ge_3_6_0() and cmap is not None: + with tm.assert_produces_warning(UserWarning, check_stacklevel=False): + ax = df.plot.scatter(x=0, y=1, cmap=cmap, **{kw: "species"}) + else: + ax = df.plot.scatter(x=0, y=1, cmap=cmap, **{kw: "species"}) assert ax.collections[0].colorbar is None def test_scatter_colors(self): From f4b92763677138ccad7861579575d86f39058bd5 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Wed, 28 Sep 2022 22:35:56 +0200 Subject: [PATCH 2/2] Move import --- pandas/tests/plotting/frame/test_frame_color.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/plotting/frame/test_frame_color.py b/pandas/tests/plotting/frame/test_frame_color.py index 28232e9d0f007..2e860c2615322 100644 --- a/pandas/tests/plotting/frame/test_frame_color.py +++ b/pandas/tests/plotting/frame/test_frame_color.py @@ -15,8 +15,6 @@ _check_plot_works, ) -from pandas.plotting._matplotlib.compat import mpl_ge_3_6_0 - @td.skip_if_no_mpl class TestDataFrameColor(TestPlotBase): @@ -201,6 +199,8 @@ def test_if_scatterplot_colorbars_are_next_to_parent_axes(self): @pytest.mark.parametrize("kw", ["c", "color"]) def test_scatter_with_c_column_name_with_colors(self, cmap, kw): # https://github.com/pandas-dev/pandas/issues/34316 + from pandas.plotting._matplotlib.compat import mpl_ge_3_6_0 + df = DataFrame( [[5.1, 3.5], [4.9, 3.0], [7.0, 3.2], [6.4, 3.2], [5.9, 3.0]], columns=["length", "width"],