From 970c2bb5f0553771ea9b6ca522eacd8f2dd3f59d Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Wed, 13 Feb 2019 13:04:31 +0000 Subject: [PATCH] TST/CLN: remove test_slice_ints_with_floats_raises (#25277) --- pandas/tests/indexes/test_base.py | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index c99007cef90d41..8415bab802239a 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -1541,8 +1541,9 @@ def test_slice_locs(self, dtype): assert index2.slice_locs(8, 2) == (2, 6) assert index2.slice_locs(7, 3) == (2, 5) - def test_slice_float_locs(self): - index = Index(np.array([0, 1, 2, 5, 6, 7, 9, 10], dtype=float)) + @pytest.mark.parametrize("dtype", [int, float]) + def test_slice_float_locs(self, dtype): + index = Index(np.array([0, 1, 2, 5, 6, 7, 9, 10], dtype=dtype)) n = len(index) assert index.slice_locs(5.0, 10.0) == (3, n) assert index.slice_locs(4.5, 10.5) == (3, 8) @@ -1551,24 +1552,6 @@ def test_slice_float_locs(self): assert index2.slice_locs(8.5, 1.5) == (2, 6) assert index2.slice_locs(10.5, -1) == (0, n) - @pytest.mark.xfail(reason="Assertions were not correct - see GH#20915") - def test_slice_ints_with_floats_raises(self): - # int slicing with floats - # GH 4892, these are all TypeErrors - index = Index(np.array([0, 1, 2, 5, 6, 7, 9, 10], dtype=int)) - n = len(index) - - pytest.raises(TypeError, - lambda: index.slice_locs(5.0, 10.0)) - pytest.raises(TypeError, - lambda: index.slice_locs(4.5, 10.5)) - - index2 = index[::-1] - pytest.raises(TypeError, - lambda: index2.slice_locs(8.5, 1.5), (2, 6)) - pytest.raises(TypeError, - lambda: index2.slice_locs(10.5, -1), (0, n)) - def test_slice_locs_dup(self): index = Index(['a', 'a', 'b', 'c', 'd', 'd']) assert index.slice_locs('a', 'd') == (0, 6)