@@ -57,15 +57,19 @@ def test_to_frame():
57
57
def test_to_hierarchical ():
58
58
index = MultiIndex .from_tuples ([(1 , 'one' ), (1 , 'two' ), (2 , 'one' ), (
59
59
2 , 'two' )])
60
- result = index .to_hierarchical (3 )
60
+ with tm .assert_produces_warning (FutureWarning ,
61
+ check_stacklevel = False ):
62
+ result = index .to_hierarchical (3 )
61
63
expected = MultiIndex (levels = [[1 , 2 ], ['one' , 'two' ]],
62
64
labels = [[0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 ],
63
65
[0 , 0 , 0 , 1 , 1 , 1 , 0 , 0 , 0 , 1 , 1 , 1 ]])
64
66
tm .assert_index_equal (result , expected )
65
67
assert result .names == index .names
66
68
67
69
# K > 1
68
- result = index .to_hierarchical (3 , 2 )
70
+ with tm .assert_produces_warning (FutureWarning ,
71
+ check_stacklevel = False ):
72
+ result = index .to_hierarchical (3 , 2 )
69
73
expected = MultiIndex (levels = [[1 , 2 ], ['one' , 'two' ]],
70
74
labels = [[0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 ],
71
75
[0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 ]])
@@ -77,7 +81,9 @@ def test_to_hierarchical():
77
81
(2 , 'a' ), (2 , 'b' )],
78
82
names = ['N1' , 'N2' ])
79
83
80
- result = index .to_hierarchical (2 )
84
+ with tm .assert_produces_warning (FutureWarning ,
85
+ check_stacklevel = False ):
86
+ result = index .to_hierarchical (2 )
81
87
expected = MultiIndex .from_tuples ([(2 , 'c' ), (2 , 'c' ), (1 , 'b' ),
82
88
(1 , 'b' ),
83
89
(2 , 'a' ), (2 , 'a' ),
0 commit comments