@@ -1541,8 +1541,9 @@ def test_slice_locs(self, dtype):
15411541 assert index2 .slice_locs (8 , 2 ) == (2 , 6 )
15421542 assert index2 .slice_locs (7 , 3 ) == (2 , 5 )
15431543
1544- def test_slice_float_locs (self ):
1545- index = Index (np .array ([0 , 1 , 2 , 5 , 6 , 7 , 9 , 10 ], dtype = float ))
1544+ @pytest .mark .parametrize ("dtype" , [int , float ])
1545+ def test_slice_float_locs (self , dtype ):
1546+ index = Index (np .array ([0 , 1 , 2 , 5 , 6 , 7 , 9 , 10 ], dtype = dtype ))
15461547 n = len (index )
15471548 assert index .slice_locs (5.0 , 10.0 ) == (3 , n )
15481549 assert index .slice_locs (4.5 , 10.5 ) == (3 , 8 )
@@ -1551,24 +1552,6 @@ def test_slice_float_locs(self):
15511552 assert index2 .slice_locs (8.5 , 1.5 ) == (2 , 6 )
15521553 assert index2 .slice_locs (10.5 , - 1 ) == (0 , n )
15531554
1554- @pytest .mark .xfail (reason = "Assertions were not correct - see GH#20915" )
1555- def test_slice_ints_with_floats_raises (self ):
1556- # int slicing with floats
1557- # GH 4892, these are all TypeErrors
1558- index = Index (np .array ([0 , 1 , 2 , 5 , 6 , 7 , 9 , 10 ], dtype = int ))
1559- n = len (index )
1560-
1561- pytest .raises (TypeError ,
1562- lambda : index .slice_locs (5.0 , 10.0 ))
1563- pytest .raises (TypeError ,
1564- lambda : index .slice_locs (4.5 , 10.5 ))
1565-
1566- index2 = index [::- 1 ]
1567- pytest .raises (TypeError ,
1568- lambda : index2 .slice_locs (8.5 , 1.5 ), (2 , 6 ))
1569- pytest .raises (TypeError ,
1570- lambda : index2 .slice_locs (10.5 , - 1 ), (0 , n ))
1571-
15721555 def test_slice_locs_dup (self ):
15731556 index = Index (['a' , 'a' , 'b' , 'c' , 'd' , 'd' ])
15741557 assert index .slice_locs ('a' , 'd' ) == (0 , 6 )
0 commit comments