11
11
import pandas ._testing as tm
12
12
13
13
14
- def test_infer_objects (idx ):
14
+ def test_infer_objects ():
15
+ idx = MultiIndex (levels = [[0 , 1 ]], codes = [[0 , 1 ]])
15
16
with pytest .raises (NotImplementedError , match = "to_frame" ):
16
17
idx .infer_objects ()
17
18
18
19
19
- def test_shift (idx ):
20
+ def test_shift ():
20
21
# GH8083 test the base class for shift
22
+ idx = MultiIndex (levels = [[0 , 1 ]], codes = [[0 , 1 ]])
21
23
msg = (
22
24
"This method is only implemented for DatetimeIndex, PeriodIndex and "
23
25
"TimedeltaIndex; Got type MultiIndex"
@@ -76,8 +78,9 @@ def test_truncate_multiindex():
76
78
# TODO: reshape
77
79
78
80
79
- def test_reorder_levels (idx ):
81
+ def test_reorder_levels ():
80
82
# this blows up
83
+ idx = MultiIndex (levels = [[0 , 1 ]], codes = [[0 , 1 ]])
81
84
with pytest .raises (IndexError , match = "^Too many levels" ):
82
85
idx .reorder_levels ([2 , 1 , 0 ])
83
86
@@ -174,9 +177,9 @@ def test_sub(idx):
174
177
first .tolist () - idx [- 3 :]
175
178
176
179
177
- def test_map (idx ):
180
+ def test_map ():
178
181
# callable
179
- index = idx
182
+ index = MultiIndex ( levels = [[ 0 , 1 ]], codes = [[ 0 , 1 ]])
180
183
181
184
result = index .map (lambda x : x )
182
185
tm .assert_index_equal (result , index )
@@ -235,10 +238,11 @@ def test_map_dictlike(idx, mapper):
235
238
],
236
239
ids = lambda func : func .__name__ ,
237
240
)
238
- def test_numpy_ufuncs (idx , func ):
241
+ def test_numpy_ufuncs (func ):
239
242
# test ufuncs of numpy. see:
240
243
# https://numpy.org/doc/stable/reference/ufuncs.html
241
244
245
+ idx = MultiIndex (levels = [["A" , "B" ]], codes = [[0 , 1 ]])
242
246
expected_exception = TypeError
243
247
msg = (
244
248
"loop of ufunc does not support argument 0 of type tuple which "
@@ -254,6 +258,7 @@ def test_numpy_ufuncs(idx, func):
254
258
ids = lambda func : func .__name__ ,
255
259
)
256
260
def test_numpy_type_funcs (idx , func ):
261
+ idx = MultiIndex (levels = [["A" , "B" ]], codes = [[0 , 1 ]])
257
262
msg = (
258
263
f"ufunc '{ func .__name__ } ' not supported for the input types, and the inputs "
259
264
"could not be safely coerced to any supported types according to "
0 commit comments