From cca06c4cb7dadc1281c8f8334eb93f48c69ddf19 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Thu, 22 Dec 2016 15:05:35 +0100 Subject: [PATCH 1/2] TST: matplotlib 2.0 fix in log limits for barplot (GH14808) --- pandas/tests/plotting/test_series.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/tests/plotting/test_series.py b/pandas/tests/plotting/test_series.py index 73119fec88198..3f7b94dc18fa2 100644 --- a/pandas/tests/plotting/test_series.py +++ b/pandas/tests/plotting/test_series.py @@ -218,8 +218,9 @@ def test_bar_log(self): expected = np.hstack((1.0e-04, expected, 1.0e+01)) ax = Series([0.1, 0.01, 0.001]).plot(log=True, kind='bar') + ymin = 0.00079432823472428218 if self.mpl_ge_2_0_0 else 0.001 ymax = 0.12589254117941673 if self.mpl_ge_2_0_0 else .10000000000000001 - self.assertEqual(ax.get_ylim(), (0.001, ymax)) + self.assertEqual(ax.get_ylim(), (ymin, ymax)) tm.assert_numpy_array_equal(ax.yaxis.get_ticklocs(), expected) tm.close() From 1f1a80d61cc1516356e72e950045ca0d55408307 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Sat, 24 Dec 2016 00:47:28 +0100 Subject: [PATCH 2/2] use assertAlmostEqual for floating point error + update expected ticklocs --- pandas/tests/plotting/test_series.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pandas/tests/plotting/test_series.py b/pandas/tests/plotting/test_series.py index 3f7b94dc18fa2..6878ca0e1bc06 100644 --- a/pandas/tests/plotting/test_series.py +++ b/pandas/tests/plotting/test_series.py @@ -216,16 +216,22 @@ def test_bar_log(self): if not self.mpl_le_1_2_1: expected = np.hstack((1.0e-04, expected, 1.0e+01)) + if self.mpl_ge_2_0_0: + expected = np.hstack((1.0e-05, expected)) ax = Series([0.1, 0.01, 0.001]).plot(log=True, kind='bar') - ymin = 0.00079432823472428218 if self.mpl_ge_2_0_0 else 0.001 + ymin = 0.0007943282347242822 if self.mpl_ge_2_0_0 else 0.001 ymax = 0.12589254117941673 if self.mpl_ge_2_0_0 else .10000000000000001 - self.assertEqual(ax.get_ylim(), (ymin, ymax)) + res = ax.get_ylim() + self.assertAlmostEqual(res[0], ymin) + self.assertAlmostEqual(res[1], ymax) tm.assert_numpy_array_equal(ax.yaxis.get_ticklocs(), expected) tm.close() ax = Series([0.1, 0.01, 0.001]).plot(log=True, kind='barh') - self.assertEqual(ax.get_xlim(), (0.001, ymax)) + res = ax.get_xlim() + self.assertAlmostEqual(res[0], ymin) + self.assertAlmostEqual(res[1], ymax) tm.assert_numpy_array_equal(ax.xaxis.get_ticklocs(), expected) @slow