1111import pandas ._testing as tm
1212
1313
14- def test_infer_objects (idx ):
14+ def test_infer_objects ():
15+ idx = MultiIndex (levels = [[0 , 1 ]], codes = [[0 , 1 ]])
1516 with pytest .raises (NotImplementedError , match = "to_frame" ):
1617 idx .infer_objects ()
1718
1819
19- def test_shift (idx ):
20+ def test_shift ():
2021 # GH8083 test the base class for shift
22+ idx = MultiIndex (levels = [[0 , 1 ]], codes = [[0 , 1 ]])
2123 msg = (
2224 "This method is only implemented for DatetimeIndex, PeriodIndex and "
2325 "TimedeltaIndex; Got type MultiIndex"
@@ -76,8 +78,9 @@ def test_truncate_multiindex():
7678# TODO: reshape
7779
7880
79- def test_reorder_levels (idx ):
81+ def test_reorder_levels ():
8082 # this blows up
83+ idx = MultiIndex (levels = [[0 , 1 ]], codes = [[0 , 1 ]])
8184 with pytest .raises (IndexError , match = "^Too many levels" ):
8285 idx .reorder_levels ([2 , 1 , 0 ])
8386
@@ -174,9 +177,9 @@ def test_sub(idx):
174177 first .tolist () - idx [- 3 :]
175178
176179
177- def test_map (idx ):
180+ def test_map ():
178181 # callable
179- index = idx
182+ index = MultiIndex ( levels = [[ 0 , 1 ]], codes = [[ 0 , 1 ]])
180183
181184 result = index .map (lambda x : x )
182185 tm .assert_index_equal (result , index )
@@ -235,10 +238,11 @@ def test_map_dictlike(idx, mapper):
235238 ],
236239 ids = lambda func : func .__name__ ,
237240)
238- def test_numpy_ufuncs (idx , func ):
241+ def test_numpy_ufuncs (func ):
239242 # test ufuncs of numpy. see:
240243 # https://numpy.org/doc/stable/reference/ufuncs.html
241244
245+ idx = MultiIndex (levels = [["A" , "B" ]], codes = [[0 , 1 ]])
242246 expected_exception = TypeError
243247 msg = (
244248 "loop of ufunc does not support argument 0 of type tuple which "
@@ -254,6 +258,7 @@ def test_numpy_ufuncs(idx, func):
254258 ids = lambda func : func .__name__ ,
255259)
256260def test_numpy_type_funcs (idx , func ):
261+ idx = MultiIndex (levels = [["A" , "B" ]], codes = [[0 , 1 ]])
257262 msg = (
258263 f"ufunc '{ func .__name__ } ' not supported for the input types, and the inputs "
259264 "could not be safely coerced to any supported types according to "
0 commit comments