2323from numpy .random import randn
2424from pandas .compat import range , lrange , lmap , zip
2525
26- from pandas import Series , TimeSeries , DataFrame
26+ from pandas import Series , TimeSeries , DataFrame , _np_version_under1p9
2727from pandas .util .testing import (assert_series_equal , assert_almost_equal ,
2828 assertRaisesRegexp )
2929import pandas .util .testing as tm
@@ -1862,8 +1862,17 @@ def test_getitem_day(self):
18621862 values = ['2014' , '2013/02' , '2013/01/02' ,
18631863 '2013/02/01 9H' , '2013/02/01 09:00' ]
18641864 for v in values :
1865- with tm .assertRaises (ValueError ):
1866- idx [v ]
1865+
1866+ if _np_version_under1p9 :
1867+ with tm .assertRaises (ValueError ):
1868+ idx [v ]
1869+ else :
1870+ # GH7116
1871+ # these show deprecations as we are trying
1872+ # to slice with non-integer indexers
1873+ #with tm.assertRaises(IndexError):
1874+ # idx[v]
1875+ continue
18671876
18681877 s = Series (np .random .rand (len (idx )), index = idx )
18691878 assert_series_equal (s ['2013/01' ], s [0 :31 ])
@@ -1910,8 +1919,16 @@ def test_getitem_seconds(self):
19101919 values = ['2014' , '2013/02' , '2013/01/02' ,
19111920 '2013/02/01 9H' , '2013/02/01 09:00' ]
19121921 for v in values :
1913- with tm .assertRaises (ValueError ):
1914- idx [v ]
1922+ if _np_version_under1p9 :
1923+ with tm .assertRaises (ValueError ):
1924+ idx [v ]
1925+ else :
1926+ # GH7116
1927+ # these show deprecations as we are trying
1928+ # to slice with non-integer indexers
1929+ #with tm.assertRaises(IndexError):
1930+ # idx[v]
1931+ continue
19151932
19161933 s = Series (np .random .rand (len (idx )), index = idx )
19171934
@@ -2291,7 +2308,7 @@ def test_factorize(self):
22912308
22922309 exp_arr = np .array ([0 , 0 , 1 , 1 , 2 , 2 ])
22932310 exp_idx = PeriodIndex (['2014-01' , '2014-02' , '2014-03' ], freq = 'M' )
2294-
2311+
22952312 arr , idx = idx1 .factorize ()
22962313 self .assert_numpy_array_equal (arr , exp_arr )
22972314 self .assert_ (idx .equals (exp_idx ))
@@ -2303,7 +2320,7 @@ def test_factorize(self):
23032320 idx2 = pd .PeriodIndex (['2014-03' , '2014-03' , '2014-02' , '2014-01' ,
23042321 '2014-03' , '2014-01' ], freq = 'M' )
23052322
2306- exp_arr = np .array ([2 , 2 , 1 , 0 , 2 , 0 ])
2323+ exp_arr = np .array ([2 , 2 , 1 , 0 , 2 , 0 ])
23072324 arr , idx = idx2 .factorize (sort = True )
23082325 self .assert_numpy_array_equal (arr , exp_arr )
23092326 self .assert_ (idx .equals (exp_idx ))
0 commit comments