Skip to content

Commit 9303315

Browse files
authored
TST: catch warnings on Panel (pandas-dev#19068)
xref pandas-dev#19059
1 parent 3198b9d commit 9303315

File tree

2 files changed

+34
-17
lines changed

2 files changed

+34
-17
lines changed

pandas/tests/generic/test_panel.py

+23
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,26 @@ def test_to_xarray(self):
3232

3333
# idempotency
3434
assert_panel_equal(result.to_pandas(), p)
35+
36+
37+
# run all the tests, but wrap each in a warning catcher
38+
for t in ['test_rename', 'test_get_numeric_data',
39+
'test_get_default', 'test_nonzero',
40+
'test_downcast', 'test_constructor_compound_dtypes',
41+
'test_head_tail',
42+
'test_size_compat', 'test_split_compat',
43+
'test_unexpected_keyword',
44+
'test_stat_unexpected_keyword', 'test_api_compat',
45+
'test_stat_non_defaults_args',
46+
'test_truncate_out_of_bounds',
47+
'test_metadata_propagation', 'test_copy_and_deepcopy',
48+
'test_sample']:
49+
50+
def f():
51+
def tester(self):
52+
f = getattr(super(TestPanel, self), t)
53+
with catch_warnings(record=True):
54+
f()
55+
return tester
56+
57+
setattr(TestPanel, t, f())

pandas/util/testing.py

+11-17
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import traceback
1414

1515
from datetime import datetime
16-
from functools import wraps, partial
16+
from functools import wraps
1717
from contextlib import contextmanager
1818

1919
from numpy.random import randn, rand
@@ -1266,14 +1266,13 @@ def assert_frame_equal(left, right, check_dtype=True,
12661266
obj='DataFrame.iloc[:, {idx}]'.format(idx=i))
12671267

12681268

1269-
def assert_panelnd_equal(left, right,
1270-
check_dtype=True,
1271-
check_panel_type=False,
1272-
check_less_precise=False,
1273-
assert_func=assert_frame_equal,
1274-
check_names=False,
1275-
by_blocks=False,
1276-
obj='Panel'):
1269+
def assert_panel_equal(left, right,
1270+
check_dtype=True,
1271+
check_panel_type=False,
1272+
check_less_precise=False,
1273+
check_names=False,
1274+
by_blocks=False,
1275+
obj='Panel'):
12771276
"""Check that left and right Panels are equal.
12781277
12791278
Parameters
@@ -1288,7 +1287,6 @@ def assert_panelnd_equal(left, right,
12881287
Specify comparison precision. Only used when check_exact is False.
12891288
5 digits (False) or 3 digits (True) after decimal points are compared.
12901289
If int, then specify the digits to compare
1291-
assert_func : function for comparing data
12921290
check_names : bool, default True
12931291
Whether to check the Index names attribute.
12941292
by_blocks : bool, default False
@@ -1322,19 +1320,15 @@ def assert_panelnd_equal(left, right,
13221320
assert item in right, msg
13231321
litem = left.iloc[i]
13241322
ritem = right.iloc[i]
1325-
assert_func(litem, ritem, check_less_precise=check_less_precise)
1323+
assert_frame_equal(litem, ritem,
1324+
check_less_precise=check_less_precise,
1325+
check_names=check_names)
13261326

13271327
for i, item in enumerate(right._get_axis(0)):
13281328
msg = "non-matching item (left) '{item}'".format(item=item)
13291329
assert item in left, msg
13301330

13311331

1332-
# TODO: strangely check_names fails in py3 ?
1333-
_panel_frame_equal = partial(assert_frame_equal, check_names=False)
1334-
assert_panel_equal = partial(assert_panelnd_equal,
1335-
assert_func=_panel_frame_equal)
1336-
1337-
13381332
# -----------------------------------------------------------------------------
13391333
# Sparse
13401334

0 commit comments

Comments
 (0)