From 1ced494d8a4ae0a68a6cea1e047d62781af52908 Mon Sep 17 00:00:00 2001 From: Maxim Ivanov Date: Fri, 6 Nov 2020 23:10:55 +0700 Subject: [PATCH 1/4] TST: fix warning for pie chart --- 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 e6a61d35365a3..7da9523f5185f 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -2654,7 +2654,7 @@ def test_pie_df_nan(self): for i in range(4): df.iloc[i, i] = np.nan fig, axes = self.plt.subplots(ncols=4) - df.plot.pie(subplots=True, ax=axes, legend=True) + df.plot.pie(subplots=True, ax=axes, legend=True, normalize=True) base_expected = ["0", "1", "2", "3"] for i, ax in enumerate(axes): From 210c06e2f29bdb968fa715756bef9dcf1dfdc818 Mon Sep 17 00:00:00 2001 From: Maxim Ivanov Date: Fri, 6 Nov 2020 23:49:40 +0700 Subject: [PATCH 2/4] TST: make applicable to mpl version >= 3.3 --- pandas/tests/plotting/test_frame.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index 7da9523f5185f..bf5b1a9634c6c 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -2650,11 +2650,20 @@ def test_pie_df(self): self._check_colors(ax.patches, facecolors=color_args) def test_pie_df_nan(self): + import matplotlib as mpl + df = DataFrame(np.random.rand(4, 4)) for i in range(4): df.iloc[i, i] = np.nan fig, axes = self.plt.subplots(ncols=4) - df.plot.pie(subplots=True, ax=axes, legend=True, normalize=True) + + # GH 37668 + if mpl.__version__ >= "3.3": + kwargs = {"normalize": True} + else: + kwargs = {} + + df.plot.pie(subplots=True, ax=axes, legend=True, **kwargs) base_expected = ["0", "1", "2", "3"] for i, ax in enumerate(axes): From 840a823be86290d257923dd521b066e2f2d9ca13 Mon Sep 17 00:00:00 2001 From: Maxim Ivanov Date: Sat, 7 Nov 2020 20:01:17 +0700 Subject: [PATCH 3/4] TST: assert no warning is raised --- pandas/tests/plotting/test_frame.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index bf5b1a9634c6c..489ca271e2d55 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -2659,11 +2659,10 @@ def test_pie_df_nan(self): # GH 37668 if mpl.__version__ >= "3.3": - kwargs = {"normalize": True} + with tm.assert_produces_warning(None): + df.plot.pie(subplots=True, ax=axes, legend=True, normalize=True) else: - kwargs = {} - - df.plot.pie(subplots=True, ax=axes, legend=True, **kwargs) + df.plot.pie(subplots=True, ax=axes, legend=True) base_expected = ["0", "1", "2", "3"] for i, ax in enumerate(axes): From 687005615bf393c972be56aa57eb51874061e6c9 Mon Sep 17 00:00:00 2001 From: Maxim Ivanov Date: Sat, 7 Nov 2020 22:01:22 +0700 Subject: [PATCH 4/4] REF: use kwargs --- 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 489ca271e2d55..48a923e85eed7 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -2658,11 +2658,12 @@ def test_pie_df_nan(self): fig, axes = self.plt.subplots(ncols=4) # GH 37668 + kwargs = {} if mpl.__version__ >= "3.3": - with tm.assert_produces_warning(None): - df.plot.pie(subplots=True, ax=axes, legend=True, normalize=True) - else: - df.plot.pie(subplots=True, ax=axes, legend=True) + kwargs = {"normalize": True} + + with tm.assert_produces_warning(None): + df.plot.pie(subplots=True, ax=axes, legend=True, **kwargs) base_expected = ["0", "1", "2", "3"] for i, ax in enumerate(axes):