From 6d3fb3b190d8a53bbc0ffa251e68c3f118062c46 Mon Sep 17 00:00:00 2001 From: Matthew Zeitlin Date: Fri, 18 Dec 2020 23:00:13 -0500 Subject: [PATCH 1/4] TST: fix some mpl warnings --- pandas/plotting/_matplotlib/misc.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pandas/plotting/_matplotlib/misc.py b/pandas/plotting/_matplotlib/misc.py index a1c62f9fce23c..3d5de2c287df9 100644 --- a/pandas/plotting/_matplotlib/misc.py +++ b/pandas/plotting/_matplotlib/misc.py @@ -144,7 +144,9 @@ def normalize(series): df = frame.drop(class_column, axis=1).apply(normalize) if ax is None: - ax = plt.gca(xlim=[-1, 1], ylim=[-1, 1]) + ax = plt.gca() + ax.set_xlim([-1, 1]) + ax.set_ylim([-1, 1]) to_plot: Dict[Label, List[List]] = {} colors = get_standard_colors( @@ -260,7 +262,8 @@ def f(t): ) colors = dict(zip(classes, color_values)) if ax is None: - ax = plt.gca(xlim=(-np.pi, np.pi)) + ax = plt.gca() + ax.set_xlim((-np.pi, np.pi)) for i in range(n): row = df.iloc[i].values f = function(row) @@ -440,7 +443,9 @@ def autocorrelation_plot( n = len(series) data = np.asarray(series) if ax is None: - ax = plt.gca(xlim=(1, n), ylim=(-1.0, 1.0)) + ax = plt.gca() + ax.set_xlim((1, n)) + ax.set_ylim((-1.0, 1.0)) mean = np.mean(data) c0 = np.sum((data - mean) ** 2) / float(n) From 025c7e13ec7534102b5038643ca1b8e682a10dbd Mon Sep 17 00:00:00 2001 From: Matthew Zeitlin Date: Mon, 21 Dec 2020 13:14:51 -0500 Subject: [PATCH 2/4] Remove redundant parens --- pandas/plotting/_matplotlib/misc.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandas/plotting/_matplotlib/misc.py b/pandas/plotting/_matplotlib/misc.py index 3d5de2c287df9..f519d1e96f5b0 100644 --- a/pandas/plotting/_matplotlib/misc.py +++ b/pandas/plotting/_matplotlib/misc.py @@ -145,8 +145,8 @@ def normalize(series): if ax is None: ax = plt.gca() - ax.set_xlim([-1, 1]) - ax.set_ylim([-1, 1]) + ax.set_xlim(-1, 1) + ax.set_ylim(-1, 1) to_plot: Dict[Label, List[List]] = {} colors = get_standard_colors( @@ -263,7 +263,7 @@ def f(t): colors = dict(zip(classes, color_values)) if ax is None: ax = plt.gca() - ax.set_xlim((-np.pi, np.pi)) + ax.set_xlim(-np.pi, np.pi) for i in range(n): row = df.iloc[i].values f = function(row) @@ -444,8 +444,8 @@ def autocorrelation_plot( data = np.asarray(series) if ax is None: ax = plt.gca() - ax.set_xlim((1, n)) - ax.set_ylim((-1.0, 1.0)) + ax.set_xlim(1, n) + ax.set_ylim(-1.0, 1.0) mean = np.mean(data) c0 = np.sum((data - mean) ** 2) / float(n) From d39f84bdf3485fc78e022169f74a4d8c6657a791 Mon Sep 17 00:00:00 2001 From: Matthew Zeitlin Date: Tue, 22 Dec 2020 15:14:17 -0500 Subject: [PATCH 3/4] Add no warning assertion --- pandas/tests/plotting/test_misc.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pandas/tests/plotting/test_misc.py b/pandas/tests/plotting/test_misc.py index 1208100ed2dce..58b0a3965b8e2 100644 --- a/pandas/tests/plotting/test_misc.py +++ b/pandas/tests/plotting/test_misc.py @@ -70,11 +70,12 @@ def setup_method(self, method): def test_autocorrelation_plot(self): from pandas.plotting import autocorrelation_plot + # Ensure no UserWarning when making plot + with tm.assert_produces_warning(None): + _check_plot_works(autocorrelation_plot, series=self.ts) + _check_plot_works(autocorrelation_plot, series=self.ts.values) - _check_plot_works(autocorrelation_plot, series=self.ts) - _check_plot_works(autocorrelation_plot, series=self.ts.values) - - ax = autocorrelation_plot(self.ts, label="Test") + ax = autocorrelation_plot(self.ts, label="Test") self._check_legend_labels(ax, labels=["Test"]) def test_lag_plot(self): @@ -132,8 +133,9 @@ def test_andrews_curves(self, iris): from pandas.plotting import andrews_curves df = iris - - _check_plot_works(andrews_curves, frame=df, class_column="Name") + # Ensure no UserWarning when making plot + with tm.assert_produces_warning(None): + _check_plot_works(andrews_curves, frame=df, class_column="Name") rgba = ("#556270", "#4ECDC4", "#C7F464") ax = _check_plot_works( @@ -280,7 +282,9 @@ def test_radviz(self, iris): from pandas.plotting import radviz df = iris - _check_plot_works(radviz, frame=df, class_column="Name") + # Ensure no UserWarning when making plot + with tm.assert_produces_warning(None): + _check_plot_works(radviz, frame=df, class_column="Name") rgba = ("#556270", "#4ECDC4", "#C7F464") ax = _check_plot_works(radviz, frame=df, class_column="Name", color=rgba) From 1cb28b595a13623d1618ebb1eddfb210cc273f86 Mon Sep 17 00:00:00 2001 From: Matthew Zeitlin Date: Tue, 22 Dec 2020 15:26:39 -0500 Subject: [PATCH 4/4] Black --- pandas/tests/plotting/test_misc.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/tests/plotting/test_misc.py b/pandas/tests/plotting/test_misc.py index 58b0a3965b8e2..ba774e8d13cf1 100644 --- a/pandas/tests/plotting/test_misc.py +++ b/pandas/tests/plotting/test_misc.py @@ -70,6 +70,7 @@ def setup_method(self, method): def test_autocorrelation_plot(self): from pandas.plotting import autocorrelation_plot + # Ensure no UserWarning when making plot with tm.assert_produces_warning(None): _check_plot_works(autocorrelation_plot, series=self.ts)