@@ -557,14 +557,10 @@ def test_pi_sub_offset_array(self, box):
557
557
def test_pi_add_iadd_int (self , one ):
558
558
# Variants of `one` for #19012
559
559
rng = pd .period_range ('2000-01-01 09:00' , freq = 'H' , periods = 10 )
560
- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ,
561
- clear = [pd .core .arrays .datetimelike ]):
562
- result = rng + one
560
+ result = rng + one
563
561
expected = pd .period_range ('2000-01-01 10:00' , freq = 'H' , periods = 10 )
564
562
tm .assert_index_equal (result , expected )
565
- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ,
566
- clear = [pd .core .arrays .datetimelike ]):
567
- rng += one
563
+ rng += one
568
564
tm .assert_index_equal (rng , expected )
569
565
570
566
def test_pi_sub_isub_int (self , one ):
@@ -573,24 +569,18 @@ def test_pi_sub_isub_int(self, one):
573
569
the integer 1, e.g. int, long, np.int64, np.uint8, ...
574
570
"""
575
571
rng = pd .period_range ('2000-01-01 09:00' , freq = 'H' , periods = 10 )
576
- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ,
577
- clear = [pd .core .arrays .datetimelike ]):
578
- result = rng - one
572
+ result = rng - one
579
573
expected = pd .period_range ('2000-01-01 08:00' , freq = 'H' , periods = 10 )
580
574
tm .assert_index_equal (result , expected )
581
- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ,
582
- clear = [pd .core .arrays .datetimelike ]):
583
- rng -= one
575
+ rng -= one
584
576
tm .assert_index_equal (rng , expected )
585
577
586
578
@pytest .mark .parametrize ('five' , [5 , np .array (5 , dtype = np .int64 )])
587
579
def test_pi_sub_intlike (self , five ):
588
580
rng = period_range ('2007-01' , periods = 50 )
589
581
590
- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ,
591
- clear = [pd .core .arrays .datetimelike ]):
592
- result = rng - five
593
- exp = rng + (- five )
582
+ result = rng - five
583
+ exp = rng + (- five )
594
584
tm .assert_index_equal (result , exp )
595
585
596
586
def test_pi_sub_isub_offset (self ):
@@ -655,9 +645,8 @@ def test_pi_add_intarray(self, int_holder, op):
655
645
# GH#19959
656
646
pi = pd .PeriodIndex ([pd .Period ('2015Q1' ), pd .Period ('NaT' )])
657
647
other = int_holder ([4 , - 1 ])
658
- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ,
659
- clear = [pd .core .arrays .datetimelike ]):
660
- result = op (pi , other )
648
+
649
+ result = op (pi , other )
661
650
expected = pd .PeriodIndex ([pd .Period ('2016Q1' ), pd .Period ('NaT' )])
662
651
tm .assert_index_equal (result , expected )
663
652
@@ -666,16 +655,13 @@ def test_pi_sub_intarray(self, int_holder):
666
655
# GH#19959
667
656
pi = pd .PeriodIndex ([pd .Period ('2015Q1' ), pd .Period ('NaT' )])
668
657
other = int_holder ([4 , - 1 ])
669
- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ,
670
- clear = [pd .core .arrays .datetimelike ]):
671
- result = pi - other
658
+
659
+ result = pi - other
672
660
expected = pd .PeriodIndex ([pd .Period ('2014Q1' ), pd .Period ('NaT' )])
673
661
tm .assert_index_equal (result , expected )
674
662
675
663
with pytest .raises (TypeError ):
676
- with tm .assert_produces_warning (FutureWarning ,
677
- check_stacklevel = False ):
678
- other - pi
664
+ other - pi
679
665
680
666
# ---------------------------------------------------------------
681
667
# Timedelta-like (timedelta, timedelta64, Timedelta, Tick)
@@ -937,12 +923,11 @@ def test_pi_ops(self):
937
923
938
924
expected = PeriodIndex (['2011-03' , '2011-04' , '2011-05' , '2011-06' ],
939
925
freq = 'M' , name = 'idx' )
940
- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ,
941
- clear = [pd .core .arrays .datetimelike ]):
942
- self ._check (idx , lambda x : x + 2 , expected )
943
- self ._check (idx , lambda x : 2 + x , expected )
944
926
945
- self ._check (idx + 2 , lambda x : x - 2 , idx )
927
+ self ._check (idx , lambda x : x + 2 , expected )
928
+ self ._check (idx , lambda x : 2 + x , expected )
929
+
930
+ self ._check (idx + 2 , lambda x : x - 2 , idx )
946
931
947
932
result = idx - Period ('2011-01' , freq = 'M' )
948
933
off = idx .freq
@@ -987,53 +972,50 @@ def test_pi_ops_nat(self):
987
972
freq = 'M' , name = 'idx' )
988
973
expected = PeriodIndex (['2011-03' , '2011-04' , 'NaT' , '2011-06' ],
989
974
freq = 'M' , name = 'idx' )
990
- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ,
991
- clear = [pd .core .arrays .datetimelike ]):
992
- self ._check (idx , lambda x : x + 2 , expected )
993
- self ._check (idx , lambda x : 2 + x , expected )
994
- self ._check (idx , lambda x : np .add (x , 2 ), expected )
995
975
996
- self ._check (idx + 2 , lambda x : x - 2 , idx )
997
- self ._check (idx + 2 , lambda x : np .subtract (x , 2 ), idx )
976
+ self ._check (idx , lambda x : x + 2 , expected )
977
+ self ._check (idx , lambda x : 2 + x , expected )
978
+ self ._check (idx , lambda x : np .add (x , 2 ), expected )
979
+
980
+ self ._check (idx + 2 , lambda x : x - 2 , idx )
981
+ self ._check (idx + 2 , lambda x : np .subtract (x , 2 ), idx )
998
982
999
983
# freq with mult
1000
984
idx = PeriodIndex (['2011-01' , '2011-02' , 'NaT' , '2011-04' ],
1001
985
freq = '2M' , name = 'idx' )
1002
986
expected = PeriodIndex (['2011-07' , '2011-08' , 'NaT' , '2011-10' ],
1003
987
freq = '2M' , name = 'idx' )
1004
- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ,
1005
- clear = [pd .core .arrays .datetimelike ]):
1006
- self ._check (idx , lambda x : x + 3 , expected )
1007
- self ._check (idx , lambda x : 3 + x , expected )
1008
- self ._check (idx , lambda x : np .add (x , 3 ), expected )
1009
988
1010
- self ._check (idx + 3 , lambda x : x - 3 , idx )
1011
- self ._check (idx + 3 , lambda x : np .subtract (x , 3 ), idx )
989
+ self ._check (idx , lambda x : x + 3 , expected )
990
+ self ._check (idx , lambda x : 3 + x , expected )
991
+ self ._check (idx , lambda x : np .add (x , 3 ), expected )
992
+
993
+ self ._check (idx + 3 , lambda x : x - 3 , idx )
994
+ self ._check (idx + 3 , lambda x : np .subtract (x , 3 ), idx )
1012
995
1013
996
def test_pi_ops_array_int (self ):
1014
- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ,
1015
- clear = [pd .core .arrays .datetimelike ]):
1016
- idx = PeriodIndex (['2011-01' , '2011-02' , 'NaT' , '2011-04' ],
1017
- freq = 'M' , name = 'idx' )
1018
- f = lambda x : x + np .array ([1 , 2 , 3 , 4 ])
1019
- exp = PeriodIndex (['2011-02' , '2011-04' , 'NaT' , '2011-08' ],
1020
- freq = 'M' , name = 'idx' )
1021
- self ._check (idx , f , exp )
1022
-
1023
- f = lambda x : np .add (x , np .array ([4 , - 1 , 1 , 2 ]))
1024
- exp = PeriodIndex (['2011-05' , '2011-01' , 'NaT' , '2011-06' ],
1025
- freq = 'M' , name = 'idx' )
1026
- self ._check (idx , f , exp )
1027
-
1028
- f = lambda x : x - np .array ([1 , 2 , 3 , 4 ])
1029
- exp = PeriodIndex (['2010-12' , '2010-12' , 'NaT' , '2010-12' ],
1030
- freq = 'M' , name = 'idx' )
1031
- self ._check (idx , f , exp )
1032
-
1033
- f = lambda x : np .subtract (x , np .array ([3 , 2 , 3 , - 2 ]))
1034
- exp = PeriodIndex (['2010-10' , '2010-12' , 'NaT' , '2011-06' ],
1035
- freq = 'M' , name = 'idx' )
1036
- self ._check (idx , f , exp )
997
+
998
+ idx = PeriodIndex (['2011-01' , '2011-02' , 'NaT' , '2011-04' ],
999
+ freq = 'M' , name = 'idx' )
1000
+ f = lambda x : x + np .array ([1 , 2 , 3 , 4 ])
1001
+ exp = PeriodIndex (['2011-02' , '2011-04' , 'NaT' , '2011-08' ],
1002
+ freq = 'M' , name = 'idx' )
1003
+ self ._check (idx , f , exp )
1004
+
1005
+ f = lambda x : np .add (x , np .array ([4 , - 1 , 1 , 2 ]))
1006
+ exp = PeriodIndex (['2011-05' , '2011-01' , 'NaT' , '2011-06' ],
1007
+ freq = 'M' , name = 'idx' )
1008
+ self ._check (idx , f , exp )
1009
+
1010
+ f = lambda x : x - np .array ([1 , 2 , 3 , 4 ])
1011
+ exp = PeriodIndex (['2010-12' , '2010-12' , 'NaT' , '2010-12' ],
1012
+ freq = 'M' , name = 'idx' )
1013
+ self ._check (idx , f , exp )
1014
+
1015
+ f = lambda x : np .subtract (x , np .array ([3 , 2 , 3 , - 2 ]))
1016
+ exp = PeriodIndex (['2010-10' , '2010-12' , 'NaT' , '2011-06' ],
1017
+ freq = 'M' , name = 'idx' )
1018
+ self ._check (idx , f , exp )
1037
1019
1038
1020
def test_pi_ops_offset (self ):
1039
1021
idx = PeriodIndex (['2011-01-01' , '2011-02-01' , '2011-03-01' ,
0 commit comments