From 2d6f5e8c72ebdf044e54fe4d004d073ec919fdc3 Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Sat, 13 Feb 2016 09:06:16 -0500 Subject: [PATCH] WARN: fix some warnings catch warning on reindexing a boolean indexer add some documentation on a na scalar comparison test warning remove warning for plotting multiple on a sub-plot --- pandas/tests/frame/test_indexing.py | 10 +++++++--- pandas/tests/series/test_operators.py | 8 ++++++++ pandas/tests/test_graphics_others.py | 14 ++++++++++---- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/pandas/tests/frame/test_indexing.py b/pandas/tests/frame/test_indexing.py index d5d0bd32a9356..7c5ec8f35bf44 100644 --- a/pandas/tests/frame/test_indexing.py +++ b/pandas/tests/frame/test_indexing.py @@ -212,9 +212,13 @@ def test_getitem_boolean(self): assert_frame_equal(subframe_obj, subframe) # test that Series indexers reindex - indexer_obj = indexer_obj.reindex(self.tsframe.index[::-1]) - subframe_obj = self.tsframe[indexer_obj] - assert_frame_equal(subframe_obj, subframe) + # we are producing a warning that since the passed boolean + # key is not the same as the given index, we will reindex + # not sure this is really necessary + with tm.assert_produces_warning(UserWarning): + indexer_obj = indexer_obj.reindex(self.tsframe.index[::-1]) + subframe_obj = self.tsframe[indexer_obj] + assert_frame_equal(subframe_obj, subframe) # test df[df > 0] for df in [self.tsframe, self.mixed_frame, diff --git a/pandas/tests/series/test_operators.py b/pandas/tests/series/test_operators.py index 5b50778d358ad..06046accaa0d9 100644 --- a/pandas/tests/series/test_operators.py +++ b/pandas/tests/series/test_operators.py @@ -1197,8 +1197,16 @@ def tester(a, b): # TODO: Fix this exception - needs to be fixed! (see GH5035) # (previously this was a TypeError because series returned # NotImplemented + + # this is an alignment issue; these are equivalent + # https://github.com/pydata/pandas/issues/5284 + + self.assertRaises(ValueError, lambda: d.__and__(s, axis='columns')) self.assertRaises(ValueError, tester, s, d) + # this is wrong as its not a boolean result + # result = d.__and__(s,axis='index') + def test_operators_corner(self): series = self.ts diff --git a/pandas/tests/test_graphics_others.py b/pandas/tests/test_graphics_others.py index 7301edcd52c3c..983d0c310f71d 100644 --- a/pandas/tests/test_graphics_others.py +++ b/pandas/tests/test_graphics_others.py @@ -425,9 +425,12 @@ def test_scatter_matrix_axis(self): with tm.RNGContext(42): df = DataFrame(randn(100, 3)) - axes = _check_plot_works(scatter_matrix, filterwarnings='always', - frame=df, range_padding=.1) + # we are plotting multiples on a sub-plot + with tm.assert_produces_warning(UserWarning): + axes = _check_plot_works(scatter_matrix, filterwarnings='always', + frame=df, range_padding=.1) axes0_labels = axes[0][0].yaxis.get_majorticklabels() + # GH 5662 expected = ['-2', '-1', '0', '1', '2'] self._check_text_labels(axes0_labels, expected) @@ -435,8 +438,11 @@ def test_scatter_matrix_axis(self): axes, xlabelsize=8, xrot=90, ylabelsize=8, yrot=0) df[0] = ((df[0] - 2) / 3) - axes = _check_plot_works(scatter_matrix, filterwarnings='always', - frame=df, range_padding=.1) + + # we are plotting multiples on a sub-plot + with tm.assert_produces_warning(UserWarning): + axes = _check_plot_works(scatter_matrix, filterwarnings='always', + frame=df, range_padding=.1) axes0_labels = axes[0][0].yaxis.get_majorticklabels() expected = ['-1.2', '-1.0', '-0.8', '-0.6', '-0.4', '-0.2', '0.0'] self._check_text_labels(axes0_labels, expected)