@@ -257,43 +257,6 @@ def test_identical(self):
257257
258258 assert not index .copy (dtype = object ).identical (index .copy (dtype = "int64" ))
259259
260- def test_get_indexer (self ):
261- index = self .create_index ()
262- target = RangeIndex (10 )
263- indexer = index .get_indexer (target )
264- expected = np .array ([0 , - 1 , 1 , - 1 , 2 , - 1 , 3 , - 1 , 4 , - 1 ], dtype = np .intp )
265- tm .assert_numpy_array_equal (indexer , expected )
266-
267- def test_get_indexer_pad (self ):
268- index = self .create_index ()
269- target = RangeIndex (10 )
270- indexer = index .get_indexer (target , method = "pad" )
271- expected = np .array ([0 , 0 , 1 , 1 , 2 , 2 , 3 , 3 , 4 , 4 ], dtype = np .intp )
272- tm .assert_numpy_array_equal (indexer , expected )
273-
274- def test_get_indexer_backfill (self ):
275- index = self .create_index ()
276- target = RangeIndex (10 )
277- indexer = index .get_indexer (target , method = "backfill" )
278- expected = np .array ([0 , 1 , 1 , 2 , 2 , 3 , 3 , 4 , 4 , 5 ], dtype = np .intp )
279- tm .assert_numpy_array_equal (indexer , expected )
280-
281- def test_get_indexer_limit (self ):
282- # GH 28631
283- idx = RangeIndex (4 )
284- target = RangeIndex (6 )
285- result = idx .get_indexer (target , method = "pad" , limit = 1 )
286- expected = np .array ([0 , 1 , 2 , 3 , 3 , - 1 ], dtype = np .intp )
287- tm .assert_numpy_array_equal (result , expected )
288-
289- @pytest .mark .parametrize ("stop" , [0 , - 1 , - 2 ])
290- def test_get_indexer_decreasing (self , stop ):
291- # GH 28678
292- index = RangeIndex (7 , stop , - 3 )
293- result = index .get_indexer (range (9 ))
294- expected = np .array ([- 1 , 2 , - 1 , - 1 , 1 , - 1 , - 1 , 0 , - 1 ], dtype = np .intp )
295- tm .assert_numpy_array_equal (result , expected )
296-
297260 def test_nbytes (self ):
298261
299262 # memory savings vs int index
@@ -327,38 +290,6 @@ def test_prevent_casting(self):
327290 result = index .astype ("O" )
328291 assert result .dtype == np .object_
329292
330- def test_take_preserve_name (self ):
331- index = RangeIndex (1 , 5 , name = "foo" )
332- taken = index .take ([3 , 0 , 1 ])
333- assert index .name == taken .name
334-
335- def test_take_fill_value (self ):
336- # GH 12631
337- idx = pd .RangeIndex (1 , 4 , name = "xxx" )
338- result = idx .take (np .array ([1 , 0 , - 1 ]))
339- expected = pd .Int64Index ([2 , 1 , 3 ], name = "xxx" )
340- tm .assert_index_equal (result , expected )
341-
342- # fill_value
343- msg = "Unable to fill values because RangeIndex cannot contain NA"
344- with pytest .raises (ValueError , match = msg ):
345- idx .take (np .array ([1 , 0 , - 1 ]), fill_value = True )
346-
347- # allow_fill=False
348- result = idx .take (np .array ([1 , 0 , - 1 ]), allow_fill = False , fill_value = True )
349- expected = pd .Int64Index ([2 , 1 , 3 ], name = "xxx" )
350- tm .assert_index_equal (result , expected )
351-
352- msg = "Unable to fill values because RangeIndex cannot contain NA"
353- with pytest .raises (ValueError , match = msg ):
354- idx .take (np .array ([1 , 0 , - 2 ]), fill_value = True )
355- with pytest .raises (ValueError , match = msg ):
356- idx .take (np .array ([1 , 0 , - 5 ]), fill_value = True )
357-
358- msg = "index -5 is out of bounds for (axis 0 with )?size 3"
359- with pytest .raises (IndexError , match = msg ):
360- idx .take (np .array ([1 , - 5 ]))
361-
362293 def test_repr_roundtrip (self ):
363294 index = self .create_index ()
364295 tm .assert_index_equal (eval (repr (index )), index )
0 commit comments