From 1c04f3cdee7cf928de334f398406911c629bc6ff Mon Sep 17 00:00:00 2001 From: Maxim Ivanov Date: Thu, 8 Oct 2020 21:35:29 +0700 Subject: [PATCH 1/6] FIX: fix cleanup warnings for errorbar timeseries --- pandas/tests/plotting/test_frame.py | 77 +++++++++++++++++++---------- 1 file changed, 52 insertions(+), 25 deletions(-) diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index bdb86d2dd846f..101cc06f3e720 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -2765,35 +2765,62 @@ def test_errorbar_with_partial_columns(self): self._check_has_errorbars(ax, xerr=0, yerr=1) @pytest.mark.slow - def test_errorbar_timeseries(self): + @pytest.mark.parametrize("kind", ["line", "bar", "barh"]) + def test_errorbar_timeseries(self, kind): + import matplotlib.pyplot as plt - with warnings.catch_warnings(): - d = {"x": np.arange(12), "y": np.arange(12, 0, -1)} - d_err = {"x": np.ones(12) * 0.2, "y": np.ones(12) * 0.4} + d = {"x": np.arange(12), "y": np.arange(12, 0, -1)} + d_err = {"x": np.ones(12) * 0.2, "y": np.ones(12) * 0.4} - # check time-series plots - ix = date_range("1/1/2000", "1/1/2001", freq="M") - tdf = DataFrame(d, index=ix) - tdf_err = DataFrame(d_err, index=ix) + # check time-series plots + ix = date_range("1/1/2000", "1/1/2001", freq="M") + tdf = DataFrame(d, index=ix) + tdf_err = DataFrame(d_err, index=ix) - kinds = ["line", "bar", "barh"] - for kind in kinds: - ax = _check_plot_works(tdf.plot, yerr=tdf_err, kind=kind) - self._check_has_errorbars(ax, xerr=0, yerr=2) - ax = _check_plot_works(tdf.plot, yerr=d_err, kind=kind) - self._check_has_errorbars(ax, xerr=0, yerr=2) - ax = _check_plot_works(tdf.plot, y="y", yerr=tdf_err["x"], kind=kind) - self._check_has_errorbars(ax, xerr=0, yerr=1) - ax = _check_plot_works(tdf.plot, y="y", yerr="x", kind=kind) - self._check_has_errorbars(ax, xerr=0, yerr=1) - ax = _check_plot_works(tdf.plot, yerr=tdf_err, kind=kind) - self._check_has_errorbars(ax, xerr=0, yerr=2) + ax = _check_plot_works(tdf.plot, yerr=tdf_err, kind=kind) + self._check_has_errorbars(ax, xerr=0, yerr=2) - # _check_plot_works adds an ax so catch warning. see GH #13188 - axes = _check_plot_works( - tdf.plot, kind=kind, yerr=tdf_err, subplots=True - ) - self._check_has_errorbars(axes, xerr=0, yerr=1) + ax = _check_plot_works(tdf.plot, yerr=d_err, kind=kind) + self._check_has_errorbars(ax, xerr=0, yerr=2) + + ax = _check_plot_works(tdf.plot, y="y", yerr=tdf_err["x"], kind=kind) + self._check_has_errorbars(ax, xerr=0, yerr=1) + + ax = _check_plot_works(tdf.plot, y="y", yerr="x", kind=kind) + self._check_has_errorbars(ax, xerr=0, yerr=1) + + ax = _check_plot_works(tdf.plot, yerr=tdf_err, kind=kind) + self._check_has_errorbars(ax, xerr=0, yerr=2) + + # Do not use _check_plot_works as this function creates + # subplots inside, which led to uncaught warnings like this: + # UserWarning: To output multiple subplots, + # the figure containing the passed axes is being cleared + tdf.plot(kind=kind, yerr=tdf_err, subplots=True) + fig = plt.gcf() + axes = fig.get_axes() + for ax in axes: + self._check_has_errorbars(ax, xerr=0, yerr=1) + + @pytest.mark.slow + @pytest.mark.parametrize("kind", ["line", "bar", "barh"]) + def test_errorbar_plotting_twice_on_same_axis_warns(self, kind): + d = {"x": np.arange(12), "y": np.arange(12, 0, -1)} + d_err = {"x": np.ones(12) * 0.2, "y": np.ones(12) * 0.4} + + ix = date_range("1/1/2000", "1/1/2001", freq="M") + tdf = DataFrame(d, index=ix) + tdf_err = DataFrame(d_err, index=ix) + + with warnings.catch_warnings(record=True) as w: + # _check_plot_works creates subplots inside, + # thus the warning about overwriting must be raised + axes = _check_plot_works(tdf.plot, kind=kind, yerr=tdf_err, subplots=True) + self._check_has_errorbars(axes, xerr=0, yerr=1) + assert len(w) == 1 + assert issubclass(w[0].category, UserWarning) + msg = "the figure containing the passed axes is being cleared" + assert msg in str(w[0].message) def test_errorbar_asymmetrical(self): From 40833807cb783d9805dd073f8a88c6829423b012 Mon Sep 17 00:00:00 2001 From: Maxim Ivanov Date: Fri, 9 Oct 2020 14:25:28 +0700 Subject: [PATCH 2/6] REF: refactor using assert_produces_warning As agreed with charlesdong1991, use assert_produces_warning and leave a comment on which warning message is emitted --- pandas/tests/plotting/test_frame.py | 38 ++++++++--------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index 101cc06f3e720..a2290b2a08bfe 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -2792,35 +2792,17 @@ def test_errorbar_timeseries(self, kind): ax = _check_plot_works(tdf.plot, yerr=tdf_err, kind=kind) self._check_has_errorbars(ax, xerr=0, yerr=2) - # Do not use _check_plot_works as this function creates - # subplots inside, which led to uncaught warnings like this: - # UserWarning: To output multiple subplots, - # the figure containing the passed axes is being cleared - tdf.plot(kind=kind, yerr=tdf_err, subplots=True) - fig = plt.gcf() - axes = fig.get_axes() - for ax in axes: - self._check_has_errorbars(ax, xerr=0, yerr=1) - - @pytest.mark.slow - @pytest.mark.parametrize("kind", ["line", "bar", "barh"]) - def test_errorbar_plotting_twice_on_same_axis_warns(self, kind): - d = {"x": np.arange(12), "y": np.arange(12, 0, -1)} - d_err = {"x": np.ones(12) * 0.2, "y": np.ones(12) * 0.4} - - ix = date_range("1/1/2000", "1/1/2001", freq="M") - tdf = DataFrame(d, index=ix) - tdf_err = DataFrame(d_err, index=ix) - - with warnings.catch_warnings(record=True) as w: - # _check_plot_works creates subplots inside, - # thus the warning about overwriting must be raised + with tm.assert_produces_warning(UserWarning): + # _check_plot_works as this function creates + # subplots inside, which leads to warnings like this: + # UserWarning: To output multiple subplots, + # the figure containing the passed axes is being cleared + # Similar warnings were observed in GH #13188 axes = _check_plot_works(tdf.plot, kind=kind, yerr=tdf_err, subplots=True) - self._check_has_errorbars(axes, xerr=0, yerr=1) - assert len(w) == 1 - assert issubclass(w[0].category, UserWarning) - msg = "the figure containing the passed axes is being cleared" - assert msg in str(w[0].message) + fig = plt.gcf() + axes = fig.get_axes() + for ax in axes: + self._check_has_errorbars(ax, xerr=0, yerr=1) def test_errorbar_asymmetrical(self): From 73bf9104265ec6684fed02825b04e0b11a469d26 Mon Sep 17 00:00:00 2001 From: Maxim Ivanov Date: Fri, 9 Oct 2020 14:36:29 +0700 Subject: [PATCH 3/6] REF: catch warning in test_errorbar_plot --- pandas/tests/plotting/test_frame.py | 116 ++++++++++++++++------------ 1 file changed, 66 insertions(+), 50 deletions(-) diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index a2290b2a08bfe..ec5963d411954 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -2658,67 +2658,83 @@ def test_pie_df_nan(self): @pytest.mark.slow def test_errorbar_plot(self): - with warnings.catch_warnings(): - d = {"x": np.arange(12), "y": np.arange(12, 0, -1)} - df = DataFrame(d) - d_err = {"x": np.ones(12) * 0.2, "y": np.ones(12) * 0.4} - df_err = DataFrame(d_err) + import matplotlib.pyplot as plt - # check line plots - ax = _check_plot_works(df.plot, yerr=df_err, logy=True) - self._check_has_errorbars(ax, xerr=0, yerr=2) - ax = _check_plot_works(df.plot, yerr=df_err, logx=True, logy=True) - self._check_has_errorbars(ax, xerr=0, yerr=2) - ax = _check_plot_works(df.plot, yerr=df_err, loglog=True) + d = {"x": np.arange(12), "y": np.arange(12, 0, -1)} + df = DataFrame(d) + d_err = {"x": np.ones(12) * 0.2, "y": np.ones(12) * 0.4} + df_err = DataFrame(d_err) + + # check line plots + ax = _check_plot_works(df.plot, yerr=df_err, logy=True) + self._check_has_errorbars(ax, xerr=0, yerr=2) + + ax = _check_plot_works(df.plot, yerr=df_err, logx=True, logy=True) + self._check_has_errorbars(ax, xerr=0, yerr=2) + + ax = _check_plot_works(df.plot, yerr=df_err, loglog=True) + self._check_has_errorbars(ax, xerr=0, yerr=2) + + kinds = ["line", "bar", "barh"] + for kind in kinds: + ax = _check_plot_works(df.plot, yerr=df_err["x"], kind=kind) self._check_has_errorbars(ax, xerr=0, yerr=2) - kinds = ["line", "bar", "barh"] - for kind in kinds: - ax = _check_plot_works(df.plot, yerr=df_err["x"], kind=kind) - self._check_has_errorbars(ax, xerr=0, yerr=2) - ax = _check_plot_works(df.plot, yerr=d_err, kind=kind) - self._check_has_errorbars(ax, xerr=0, yerr=2) - ax = _check_plot_works(df.plot, yerr=df_err, xerr=df_err, kind=kind) - self._check_has_errorbars(ax, xerr=2, yerr=2) - ax = _check_plot_works( - df.plot, yerr=df_err["x"], xerr=df_err["x"], kind=kind - ) - self._check_has_errorbars(ax, xerr=2, yerr=2) - ax = _check_plot_works(df.plot, xerr=0.2, yerr=0.2, kind=kind) - self._check_has_errorbars(ax, xerr=2, yerr=2) + ax = _check_plot_works(df.plot, yerr=d_err, kind=kind) + self._check_has_errorbars(ax, xerr=0, yerr=2) - # _check_plot_works adds an ax so catch warning. see GH #13188 - axes = _check_plot_works( - df.plot, yerr=df_err, xerr=df_err, subplots=True, kind=kind - ) - self._check_has_errorbars(axes, xerr=1, yerr=1) + ax = _check_plot_works(df.plot, yerr=df_err, xerr=df_err, kind=kind) + self._check_has_errorbars(ax, xerr=2, yerr=2) ax = _check_plot_works( - (df + 1).plot, yerr=df_err, xerr=df_err, kind="bar", log=True + df.plot, yerr=df_err["x"], xerr=df_err["x"], kind=kind ) self._check_has_errorbars(ax, xerr=2, yerr=2) - # yerr is raw error values - ax = _check_plot_works(df["y"].plot, yerr=np.ones(12) * 0.4) - self._check_has_errorbars(ax, xerr=0, yerr=1) - ax = _check_plot_works(df.plot, yerr=np.ones((2, 12)) * 0.4) - self._check_has_errorbars(ax, xerr=0, yerr=2) + ax = _check_plot_works(df.plot, xerr=0.2, yerr=0.2, kind=kind) + self._check_has_errorbars(ax, xerr=2, yerr=2) - # yerr is column name - for yerr in ["yerr", "誤差"]: - s_df = df.copy() - s_df[yerr] = np.ones(12) * 0.2 - ax = _check_plot_works(s_df.plot, yerr=yerr) - self._check_has_errorbars(ax, xerr=0, yerr=2) - ax = _check_plot_works(s_df.plot, y="y", x="x", yerr=yerr) - self._check_has_errorbars(ax, xerr=0, yerr=1) + with tm.assert_produces_warning(UserWarning): + # _check_plot_works as this function creates + # subplots inside, which leads to warnings like this: + # UserWarning: To output multiple subplots, + # the figure containing the passed axes is being cleared + # Similar warnings were observed in GH #13188 + _check_plot_works( + df.plot, yerr=df_err, xerr=df_err, subplots=True, kind=kind + ) + fig = plt.gcf() + axes = fig.get_axes() + for ax in axes: + self._check_has_errorbars(ax, xerr=1, yerr=1) - with pytest.raises(ValueError): - df.plot(yerr=np.random.randn(11)) + ax = _check_plot_works( + (df + 1).plot, yerr=df_err, xerr=df_err, kind="bar", log=True + ) + self._check_has_errorbars(ax, xerr=2, yerr=2) + + # yerr is raw error values + ax = _check_plot_works(df["y"].plot, yerr=np.ones(12) * 0.4) + self._check_has_errorbars(ax, xerr=0, yerr=1) + + ax = _check_plot_works(df.plot, yerr=np.ones((2, 12)) * 0.4) + self._check_has_errorbars(ax, xerr=0, yerr=2) + + # yerr is column name + for yerr in ["yerr", "誤差"]: + s_df = df.copy() + s_df[yerr] = np.ones(12) * 0.2 + ax = _check_plot_works(s_df.plot, yerr=yerr) + self._check_has_errorbars(ax, xerr=0, yerr=2) + ax = _check_plot_works(s_df.plot, y="y", x="x", yerr=yerr) + self._check_has_errorbars(ax, xerr=0, yerr=1) + + with pytest.raises(ValueError): + df.plot(yerr=np.random.randn(11)) - df_err = DataFrame({"x": ["zzz"] * 12, "y": ["zzz"] * 12}) - with pytest.raises((ValueError, TypeError)): - df.plot(yerr=df_err) + df_err = DataFrame({"x": ["zzz"] * 12, "y": ["zzz"] * 12}) + with pytest.raises((ValueError, TypeError)): + df.plot(yerr=df_err) @pytest.mark.xfail(reason="Iterator is consumed", raises=ValueError) @pytest.mark.slow @@ -2798,7 +2814,7 @@ def test_errorbar_timeseries(self, kind): # UserWarning: To output multiple subplots, # the figure containing the passed axes is being cleared # Similar warnings were observed in GH #13188 - axes = _check_plot_works(tdf.plot, kind=kind, yerr=tdf_err, subplots=True) + _check_plot_works(tdf.plot, kind=kind, yerr=tdf_err, subplots=True) fig = plt.gcf() axes = fig.get_axes() for ax in axes: From d5a9e5e75e729434d7d013649d674bd722bcaf31 Mon Sep 17 00:00:00 2001 From: Maxim Ivanov Date: Fri, 9 Oct 2020 14:39:58 +0700 Subject: [PATCH 4/6] REF: extract test_errorbar_plot_different_kinds Extract test_errorbar_plot_different_kinds from test_errorbar_plot and parametrize it. --- pandas/tests/plotting/test_frame.py | 76 ++++++++++++++++------------- 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index ec5963d411954..ff478f6712ac0 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -2658,8 +2658,6 @@ def test_pie_df_nan(self): @pytest.mark.slow def test_errorbar_plot(self): - import matplotlib.pyplot as plt - d = {"x": np.arange(12), "y": np.arange(12, 0, -1)} df = DataFrame(d) d_err = {"x": np.ones(12) * 0.2, "y": np.ones(12) * 0.4} @@ -2675,39 +2673,6 @@ def test_errorbar_plot(self): ax = _check_plot_works(df.plot, yerr=df_err, loglog=True) self._check_has_errorbars(ax, xerr=0, yerr=2) - kinds = ["line", "bar", "barh"] - for kind in kinds: - ax = _check_plot_works(df.plot, yerr=df_err["x"], kind=kind) - self._check_has_errorbars(ax, xerr=0, yerr=2) - - ax = _check_plot_works(df.plot, yerr=d_err, kind=kind) - self._check_has_errorbars(ax, xerr=0, yerr=2) - - ax = _check_plot_works(df.plot, yerr=df_err, xerr=df_err, kind=kind) - self._check_has_errorbars(ax, xerr=2, yerr=2) - - ax = _check_plot_works( - df.plot, yerr=df_err["x"], xerr=df_err["x"], kind=kind - ) - self._check_has_errorbars(ax, xerr=2, yerr=2) - - ax = _check_plot_works(df.plot, xerr=0.2, yerr=0.2, kind=kind) - self._check_has_errorbars(ax, xerr=2, yerr=2) - - with tm.assert_produces_warning(UserWarning): - # _check_plot_works as this function creates - # subplots inside, which leads to warnings like this: - # UserWarning: To output multiple subplots, - # the figure containing the passed axes is being cleared - # Similar warnings were observed in GH #13188 - _check_plot_works( - df.plot, yerr=df_err, xerr=df_err, subplots=True, kind=kind - ) - fig = plt.gcf() - axes = fig.get_axes() - for ax in axes: - self._check_has_errorbars(ax, xerr=1, yerr=1) - ax = _check_plot_works( (df + 1).plot, yerr=df_err, xerr=df_err, kind="bar", log=True ) @@ -2724,8 +2689,10 @@ def test_errorbar_plot(self): for yerr in ["yerr", "誤差"]: s_df = df.copy() s_df[yerr] = np.ones(12) * 0.2 + ax = _check_plot_works(s_df.plot, yerr=yerr) self._check_has_errorbars(ax, xerr=0, yerr=2) + ax = _check_plot_works(s_df.plot, y="y", x="x", yerr=yerr) self._check_has_errorbars(ax, xerr=0, yerr=1) @@ -2736,6 +2703,45 @@ def test_errorbar_plot(self): with pytest.raises((ValueError, TypeError)): df.plot(yerr=df_err) + @pytest.mark.slow + @pytest.mark.parametrize("kind", ["line", "bar", "barh"]) + def test_errorbar_plot_different_kinds(self, kind): + import matplotlib.pyplot as plt + + d = {"x": np.arange(12), "y": np.arange(12, 0, -1)} + df = DataFrame(d) + d_err = {"x": np.ones(12) * 0.2, "y": np.ones(12) * 0.4} + df_err = DataFrame(d_err) + + ax = _check_plot_works(df.plot, yerr=df_err["x"], kind=kind) + self._check_has_errorbars(ax, xerr=0, yerr=2) + + ax = _check_plot_works(df.plot, yerr=d_err, kind=kind) + self._check_has_errorbars(ax, xerr=0, yerr=2) + + ax = _check_plot_works(df.plot, yerr=df_err, xerr=df_err, kind=kind) + self._check_has_errorbars(ax, xerr=2, yerr=2) + + ax = _check_plot_works(df.plot, yerr=df_err["x"], xerr=df_err["x"], kind=kind) + self._check_has_errorbars(ax, xerr=2, yerr=2) + + ax = _check_plot_works(df.plot, xerr=0.2, yerr=0.2, kind=kind) + self._check_has_errorbars(ax, xerr=2, yerr=2) + + with tm.assert_produces_warning(UserWarning): + # _check_plot_works as this function creates + # subplots inside, which leads to warnings like this: + # UserWarning: To output multiple subplots, + # the figure containing the passed axes is being cleared + # Similar warnings were observed in GH #13188 + _check_plot_works( + df.plot, yerr=df_err, xerr=df_err, subplots=True, kind=kind + ) + fig = plt.gcf() + axes = fig.get_axes() + for ax in axes: + self._check_has_errorbars(ax, xerr=1, yerr=1) + @pytest.mark.xfail(reason="Iterator is consumed", raises=ValueError) @pytest.mark.slow def test_errorbar_plot_iterator(self): From 198fd1eec298ab08a1c75b6e70642b2a0f462b62 Mon Sep 17 00:00:00 2001 From: Maxim Ivanov Date: Fri, 9 Oct 2020 15:23:16 +0700 Subject: [PATCH 5/6] REF: check errorbars for list-like axes --- pandas/tests/plotting/test_frame.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index ff478f6712ac0..76403a6b967e0 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -2706,8 +2706,6 @@ def test_errorbar_plot(self): @pytest.mark.slow @pytest.mark.parametrize("kind", ["line", "bar", "barh"]) def test_errorbar_plot_different_kinds(self, kind): - import matplotlib.pyplot as plt - d = {"x": np.arange(12), "y": np.arange(12, 0, -1)} df = DataFrame(d) d_err = {"x": np.ones(12) * 0.2, "y": np.ones(12) * 0.4} @@ -2734,13 +2732,10 @@ def test_errorbar_plot_different_kinds(self, kind): # UserWarning: To output multiple subplots, # the figure containing the passed axes is being cleared # Similar warnings were observed in GH #13188 - _check_plot_works( + axes = _check_plot_works( df.plot, yerr=df_err, xerr=df_err, subplots=True, kind=kind ) - fig = plt.gcf() - axes = fig.get_axes() - for ax in axes: - self._check_has_errorbars(ax, xerr=1, yerr=1) + self._check_has_errorbars(axes, xerr=1, yerr=1) @pytest.mark.xfail(reason="Iterator is consumed", raises=ValueError) @pytest.mark.slow @@ -2789,8 +2784,6 @@ def test_errorbar_with_partial_columns(self): @pytest.mark.slow @pytest.mark.parametrize("kind", ["line", "bar", "barh"]) def test_errorbar_timeseries(self, kind): - import matplotlib.pyplot as plt - d = {"x": np.arange(12), "y": np.arange(12, 0, -1)} d_err = {"x": np.ones(12) * 0.2, "y": np.ones(12) * 0.4} @@ -2820,11 +2813,8 @@ def test_errorbar_timeseries(self, kind): # UserWarning: To output multiple subplots, # the figure containing the passed axes is being cleared # Similar warnings were observed in GH #13188 - _check_plot_works(tdf.plot, kind=kind, yerr=tdf_err, subplots=True) - fig = plt.gcf() - axes = fig.get_axes() - for ax in axes: - self._check_has_errorbars(ax, xerr=0, yerr=1) + axes = _check_plot_works(tdf.plot, kind=kind, yerr=tdf_err, subplots=True) + self._check_has_errorbars(axes, xerr=0, yerr=1) def test_errorbar_asymmetrical(self): From 762b9b95c130307de762a61eb67f7e6c34015a25 Mon Sep 17 00:00:00 2001 From: Maxim Ivanov Date: Fri, 9 Oct 2020 15:26:52 +0700 Subject: [PATCH 6/6] FIX: fix comments --- pandas/tests/plotting/test_frame.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index 76403a6b967e0..b51ce375a7ed7 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -2727,8 +2727,8 @@ def test_errorbar_plot_different_kinds(self, kind): self._check_has_errorbars(ax, xerr=2, yerr=2) with tm.assert_produces_warning(UserWarning): - # _check_plot_works as this function creates - # subplots inside, which leads to warnings like this: + # _check_plot_works creates subplots inside, + # which leads to warnings like this: # UserWarning: To output multiple subplots, # the figure containing the passed axes is being cleared # Similar warnings were observed in GH #13188 @@ -2808,8 +2808,8 @@ def test_errorbar_timeseries(self, kind): self._check_has_errorbars(ax, xerr=0, yerr=2) with tm.assert_produces_warning(UserWarning): - # _check_plot_works as this function creates - # subplots inside, which leads to warnings like this: + # _check_plot_works creates subplots inside, + # which leads to warnings like this: # UserWarning: To output multiple subplots, # the figure containing the passed axes is being cleared # Similar warnings were observed in GH #13188