25
25
from pandas .compat import range , lrange , lmap , zip , text_type , PY3
26
26
from pandas .compat .numpy_compat import np_datetime64_compat
27
27
28
- from pandas import Series , DataFrame , _np_version_under1p9
28
+ from pandas import (Series , DataFrame ,
29
+ _np_version_under1p9 , _np_version_under1p11 )
29
30
from pandas import tslib
30
31
from pandas .util .testing import (assert_series_equal , assert_almost_equal ,
31
32
assertRaisesRegexp )
@@ -2580,12 +2581,15 @@ def test_range_slice_day(self):
2580
2581
didx = DatetimeIndex (start = '2013/01/01' , freq = 'D' , periods = 400 )
2581
2582
pidx = PeriodIndex (start = '2013/01/01' , freq = 'D' , periods = 400 )
2582
2583
2584
+ # changed to TypeError in 1.11
2585
+ exc = IndexError if _np_version_under1p11 else TypeError
2586
+
2583
2587
for idx in [didx , pidx ]:
2584
2588
# slices against index should raise IndexError
2585
2589
values = ['2014' , '2013/02' , '2013/01/02' , '2013/02/01 9H' ,
2586
2590
'2013/02/01 09:00' ]
2587
2591
for v in values :
2588
- with tm .assertRaises (IndexError ):
2592
+ with tm .assertRaises (exc ):
2589
2593
idx [v :]
2590
2594
2591
2595
s = Series (np .random .rand (len (idx )), index = idx )
@@ -2597,7 +2601,7 @@ def test_range_slice_day(self):
2597
2601
2598
2602
invalid = ['2013/02/01 9H' , '2013/02/01 09:00' ]
2599
2603
for v in invalid :
2600
- with tm .assertRaises (IndexError ):
2604
+ with tm .assertRaises (exc ):
2601
2605
idx [v :]
2602
2606
2603
2607
def test_getitem_seconds (self ):
@@ -2634,12 +2638,15 @@ def test_range_slice_seconds(self):
2634
2638
periods = 4000 )
2635
2639
pidx = PeriodIndex (start = '2013/01/01 09:00:00' , freq = 'S' , periods = 4000 )
2636
2640
2641
+ # changed to TypeError in 1.11
2642
+ exc = IndexError if _np_version_under1p11 else TypeError
2643
+
2637
2644
for idx in [didx , pidx ]:
2638
2645
# slices against index should raise IndexError
2639
2646
values = ['2014' , '2013/02' , '2013/01/02' , '2013/02/01 9H' ,
2640
2647
'2013/02/01 09:00' ]
2641
2648
for v in values :
2642
- with tm .assertRaises (IndexError ):
2649
+ with tm .assertRaises (exc ):
2643
2650
idx [v :]
2644
2651
2645
2652
s = Series (np .random .rand (len (idx )), index = idx )
0 commit comments