Skip to content

Commit de4dbd0

Browse files
author
Hyungtae Kim
committed
BUG: add 'import warnings' statement in panel.py (GH8152)
1 parent b70928a commit de4dbd0

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

doc/source/v0.15.0.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,3 +648,4 @@ Bug Fixes
648648
was a tuple (:issue:`8121`).
649649

650650

651+
- Bug in ``panel.py`` where Panel uses ``warnings`` module without importing (:issue:`8152`).

pandas/core/panel.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
OrderedDefaultdict)
88
from pandas import compat
99
import sys
10+
import warnings
1011
import numpy as np
1112
from pandas.core.common import (PandasError, _try_sort, _default_index,
1213
_infer_dtype_from_scalar, notnull)

pandas/tests/test_panel.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
assert_frame_equal,
1919
assert_series_equal,
2020
assert_almost_equal,
21+
assert_produces_warning,
2122
ensure_clean,
2223
assertRaisesRegexp,
2324
makeCustomDataframe as mkdf,
@@ -2324,6 +2325,13 @@ def test_panel_index():
23242325
np.repeat([1, 2, 3], 4)])
23252326
assert(index.equals(expected))
23262327

2328+
2329+
def test_import_warnings():
2330+
# GH8152
2331+
panel = Panel(np.random.rand(3, 3, 3))
2332+
with assert_produces_warning():
2333+
panel.major_xs(1, copy=False)
2334+
23272335
if __name__ == '__main__':
23282336
import nose
23292337
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],

0 commit comments

Comments
 (0)