Skip to content

Commit 76cb401

Browse files
committed
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 closes #12320 closes #8397
1 parent d4ece13 commit 76cb401

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

pandas/tests/frame/test_indexing.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,13 @@ def test_getitem_boolean(self):
212212
assert_frame_equal(subframe_obj, subframe)
213213

214214
# test that Series indexers reindex
215-
indexer_obj = indexer_obj.reindex(self.tsframe.index[::-1])
216-
subframe_obj = self.tsframe[indexer_obj]
217-
assert_frame_equal(subframe_obj, subframe)
215+
# we are producing a warning that since the passed boolean
216+
# key is not the same as the given index, we will reindex
217+
# not sure this is really necessary
218+
with tm.assert_produces_warning(UserWarning):
219+
indexer_obj = indexer_obj.reindex(self.tsframe.index[::-1])
220+
subframe_obj = self.tsframe[indexer_obj]
221+
assert_frame_equal(subframe_obj, subframe)
218222

219223
# test df[df > 0]
220224
for df in [self.tsframe, self.mixed_frame,

pandas/tests/series/test_operators.py

+8
Original file line numberDiff line numberDiff line change
@@ -1197,8 +1197,16 @@ def tester(a, b):
11971197
# TODO: Fix this exception - needs to be fixed! (see GH5035)
11981198
# (previously this was a TypeError because series returned
11991199
# NotImplemented
1200+
1201+
# this is an alignment issue; these are equivalent
1202+
# https://github.com/pydata/pandas/issues/5284
1203+
1204+
self.assertRaises(ValueError, lambda: d.__and__(s, axis='columns'))
12001205
self.assertRaises(ValueError, tester, s, d)
12011206

1207+
# this is wrong as its not a boolean result
1208+
# result = d.__and__(s,axis='index')
1209+
12021210
def test_operators_corner(self):
12031211
series = self.ts
12041212

pandas/tests/test_graphics_others.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -425,18 +425,24 @@ def test_scatter_matrix_axis(self):
425425
with tm.RNGContext(42):
426426
df = DataFrame(randn(100, 3))
427427

428-
axes = _check_plot_works(scatter_matrix, filterwarnings='always',
429-
frame=df, range_padding=.1)
428+
# we are plotting multiples on a sub-plot
429+
with tm.assert_produces_warning(UserWarning):
430+
axes = _check_plot_works(scatter_matrix, filterwarnings='always',
431+
frame=df, range_padding=.1)
430432
axes0_labels = axes[0][0].yaxis.get_majorticklabels()
433+
431434
# GH 5662
432435
expected = ['-2', '-1', '0', '1', '2']
433436
self._check_text_labels(axes0_labels, expected)
434437
self._check_ticks_props(
435438
axes, xlabelsize=8, xrot=90, ylabelsize=8, yrot=0)
436439

437440
df[0] = ((df[0] - 2) / 3)
438-
axes = _check_plot_works(scatter_matrix, filterwarnings='always',
439-
frame=df, range_padding=.1)
441+
442+
# we are plotting multiples on a sub-plot
443+
with tm.assert_produces_warning(UserWarning):
444+
axes = _check_plot_works(scatter_matrix, filterwarnings='always',
445+
frame=df, range_padding=.1)
440446
axes0_labels = axes[0][0].yaxis.get_majorticklabels()
441447
expected = ['-1.2', '-1.0', '-0.8', '-0.6', '-0.4', '-0.2', '0.0']
442448
self._check_text_labels(axes0_labels, expected)

0 commit comments

Comments
 (0)