@@ -1541,8 +1541,9 @@ def test_slice_locs(self, dtype):
1541
1541
assert index2 .slice_locs (8 , 2 ) == (2 , 6 )
1542
1542
assert index2 .slice_locs (7 , 3 ) == (2 , 5 )
1543
1543
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 ))
1546
1547
n = len (index )
1547
1548
assert index .slice_locs (5.0 , 10.0 ) == (3 , n )
1548
1549
assert index .slice_locs (4.5 , 10.5 ) == (3 , 8 )
@@ -1551,24 +1552,6 @@ def test_slice_float_locs(self):
1551
1552
assert index2 .slice_locs (8.5 , 1.5 ) == (2 , 6 )
1552
1553
assert index2 .slice_locs (10.5 , - 1 ) == (0 , n )
1553
1554
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
-
1572
1555
def test_slice_locs_dup (self ):
1573
1556
index = Index (['a' , 'a' , 'b' , 'c' , 'd' , 'd' ])
1574
1557
assert index .slice_locs ('a' , 'd' ) == (0 , 6 )
0 commit comments