@@ -659,14 +659,10 @@ def test_pi_sub_offset_array(self, box):
659
659
def test_pi_add_iadd_int (self , one ):
660
660
# Variants of `one` for #19012
661
661
rng = pd .period_range ('2000-01-01 09:00' , freq = 'H' , periods = 10 )
662
- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ,
663
- clear = [pd .core .arrays .datetimelike ]):
664
- result = rng + one
662
+ result = rng + one
665
663
expected = pd .period_range ('2000-01-01 10:00' , freq = 'H' , periods = 10 )
666
664
tm .assert_index_equal (result , expected )
667
- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ,
668
- clear = [pd .core .arrays .datetimelike ]):
669
- rng += one
665
+ rng += one
670
666
tm .assert_index_equal (rng , expected )
671
667
672
668
def test_pi_sub_isub_int (self , one ):
@@ -675,24 +671,18 @@ def test_pi_sub_isub_int(self, one):
675
671
the integer 1, e.g. int, long, np.int64, np.uint8, ...
676
672
"""
677
673
rng = pd .period_range ('2000-01-01 09:00' , freq = 'H' , periods = 10 )
678
- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ,
679
- clear = [pd .core .arrays .datetimelike ]):
680
- result = rng - one
674
+ result = rng - one
681
675
expected = pd .period_range ('2000-01-01 08:00' , freq = 'H' , periods = 10 )
682
676
tm .assert_index_equal (result , expected )
683
- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ,
684
- clear = [pd .core .arrays .datetimelike ]):
685
- rng -= one
677
+ rng -= one
686
678
tm .assert_index_equal (rng , expected )
687
679
688
680
@pytest .mark .parametrize ('five' , [5 , np .array (5 , dtype = np .int64 )])
689
681
def test_pi_sub_intlike (self , five ):
690
682
rng = period_range ('2007-01' , periods = 50 )
691
683
692
- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ,
693
- clear = [pd .core .arrays .datetimelike ]):
694
- result = rng - five
695
- exp = rng + (- five )
684
+ result = rng - five
685
+ exp = rng + (- five )
696
686
tm .assert_index_equal (result , exp )
697
687
698
688
def test_pi_sub_isub_offset (self ):
@@ -757,9 +747,8 @@ def test_pi_add_intarray(self, int_holder, op):
757
747
# GH#19959
758
748
pi = pd .PeriodIndex ([pd .Period ('2015Q1' ), pd .Period ('NaT' )])
759
749
other = int_holder ([4 , - 1 ])
760
- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ,
761
- clear = [pd .core .arrays .datetimelike ]):
762
- result = op (pi , other )
750
+
751
+ result = op (pi , other )
763
752
expected = pd .PeriodIndex ([pd .Period ('2016Q1' ), pd .Period ('NaT' )])
764
753
tm .assert_index_equal (result , expected )
765
754
@@ -768,16 +757,13 @@ def test_pi_sub_intarray(self, int_holder):
768
757
# GH#19959
769
758
pi = pd .PeriodIndex ([pd .Period ('2015Q1' ), pd .Period ('NaT' )])
770
759
other = int_holder ([4 , - 1 ])
771
- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ,
772
- clear = [pd .core .arrays .datetimelike ]):
773
- result = pi - other
760
+
761
+ result = pi - other
774
762
expected = pd .PeriodIndex ([pd .Period ('2014Q1' ), pd .Period ('NaT' )])
775
763
tm .assert_index_equal (result , expected )
776
764
777
765
with pytest .raises (TypeError ):
778
- with tm .assert_produces_warning (FutureWarning ,
779
- check_stacklevel = False ):
780
- other - pi
766
+ other - pi
781
767
782
768
# ---------------------------------------------------------------
783
769
# Timedelta-like (timedelta, timedelta64, Timedelta, Tick)
@@ -1039,12 +1025,11 @@ def test_pi_ops(self):
1039
1025
1040
1026
expected = PeriodIndex (['2011-03' , '2011-04' , '2011-05' , '2011-06' ],
1041
1027
freq = 'M' , name = 'idx' )
1042
- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ,
1043
- clear = [pd .core .arrays .datetimelike ]):
1044
- self ._check (idx , lambda x : x + 2 , expected )
1045
- self ._check (idx , lambda x : 2 + x , expected )
1046
1028
1047
- self ._check (idx + 2 , lambda x : x - 2 , idx )
1029
+ self ._check (idx , lambda x : x + 2 , expected )
1030
+ self ._check (idx , lambda x : 2 + x , expected )
1031
+
1032
+ self ._check (idx + 2 , lambda x : x - 2 , idx )
1048
1033
1049
1034
result = idx - Period ('2011-01' , freq = 'M' )
1050
1035
off = idx .freq
@@ -1089,53 +1074,50 @@ def test_pi_ops_nat(self):
1089
1074
freq = 'M' , name = 'idx' )
1090
1075
expected = PeriodIndex (['2011-03' , '2011-04' , 'NaT' , '2011-06' ],
1091
1076
freq = 'M' , name = 'idx' )
1092
- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ,
1093
- clear = [pd .core .arrays .datetimelike ]):
1094
- self ._check (idx , lambda x : x + 2 , expected )
1095
- self ._check (idx , lambda x : 2 + x , expected )
1096
- self ._check (idx , lambda x : np .add (x , 2 ), expected )
1097
1077
1098
- self ._check (idx + 2 , lambda x : x - 2 , idx )
1099
- self ._check (idx + 2 , lambda x : np .subtract (x , 2 ), idx )
1078
+ self ._check (idx , lambda x : x + 2 , expected )
1079
+ self ._check (idx , lambda x : 2 + x , expected )
1080
+ self ._check (idx , lambda x : np .add (x , 2 ), expected )
1081
+
1082
+ self ._check (idx + 2 , lambda x : x - 2 , idx )
1083
+ self ._check (idx + 2 , lambda x : np .subtract (x , 2 ), idx )
1100
1084
1101
1085
# freq with mult
1102
1086
idx = PeriodIndex (['2011-01' , '2011-02' , 'NaT' , '2011-04' ],
1103
1087
freq = '2M' , name = 'idx' )
1104
1088
expected = PeriodIndex (['2011-07' , '2011-08' , 'NaT' , '2011-10' ],
1105
1089
freq = '2M' , name = 'idx' )
1106
- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ,
1107
- clear = [pd .core .arrays .datetimelike ]):
1108
- self ._check (idx , lambda x : x + 3 , expected )
1109
- self ._check (idx , lambda x : 3 + x , expected )
1110
- self ._check (idx , lambda x : np .add (x , 3 ), expected )
1111
1090
1112
- self ._check (idx + 3 , lambda x : x - 3 , idx )
1113
- self ._check (idx + 3 , lambda x : np .subtract (x , 3 ), idx )
1091
+ self ._check (idx , lambda x : x + 3 , expected )
1092
+ self ._check (idx , lambda x : 3 + x , expected )
1093
+ self ._check (idx , lambda x : np .add (x , 3 ), expected )
1094
+
1095
+ self ._check (idx + 3 , lambda x : x - 3 , idx )
1096
+ self ._check (idx + 3 , lambda x : np .subtract (x , 3 ), idx )
1114
1097
1115
1098
def test_pi_ops_array_int (self ):
1116
- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ,
1117
- clear = [pd .core .arrays .datetimelike ]):
1118
- idx = PeriodIndex (['2011-01' , '2011-02' , 'NaT' , '2011-04' ],
1119
- freq = 'M' , name = 'idx' )
1120
- f = lambda x : x + np .array ([1 , 2 , 3 , 4 ])
1121
- exp = PeriodIndex (['2011-02' , '2011-04' , 'NaT' , '2011-08' ],
1122
- freq = 'M' , name = 'idx' )
1123
- self ._check (idx , f , exp )
1124
-
1125
- f = lambda x : np .add (x , np .array ([4 , - 1 , 1 , 2 ]))
1126
- exp = PeriodIndex (['2011-05' , '2011-01' , 'NaT' , '2011-06' ],
1127
- freq = 'M' , name = 'idx' )
1128
- self ._check (idx , f , exp )
1129
-
1130
- f = lambda x : x - np .array ([1 , 2 , 3 , 4 ])
1131
- exp = PeriodIndex (['2010-12' , '2010-12' , 'NaT' , '2010-12' ],
1132
- freq = 'M' , name = 'idx' )
1133
- self ._check (idx , f , exp )
1134
-
1135
- f = lambda x : np .subtract (x , np .array ([3 , 2 , 3 , - 2 ]))
1136
- exp = PeriodIndex (['2010-10' , '2010-12' , 'NaT' , '2011-06' ],
1137
- freq = 'M' , name = 'idx' )
1138
- self ._check (idx , f , exp )
1099
+
1100
+ idx = PeriodIndex (['2011-01' , '2011-02' , 'NaT' , '2011-04' ],
1101
+ freq = 'M' , name = 'idx' )
1102
+ f = lambda x : x + np .array ([1 , 2 , 3 , 4 ])
1103
+ exp = PeriodIndex (['2011-02' , '2011-04' , 'NaT' , '2011-08' ],
1104
+ freq = 'M' , name = 'idx' )
1105
+ self ._check (idx , f , exp )
1106
+
1107
+ f = lambda x : np .add (x , np .array ([4 , - 1 , 1 , 2 ]))
1108
+ exp = PeriodIndex (['2011-05' , '2011-01' , 'NaT' , '2011-06' ],
1109
+ freq = 'M' , name = 'idx' )
1110
+ self ._check (idx , f , exp )
1111
+
1112
+ f = lambda x : x - np .array ([1 , 2 , 3 , 4 ])
1113
+ exp = PeriodIndex (['2010-12' , '2010-12' , 'NaT' , '2010-12' ],
1114
+ freq = 'M' , name = 'idx' )
1115
+ self ._check (idx , f , exp )
1116
+
1117
+ f = lambda x : np .subtract (x , np .array ([3 , 2 , 3 , - 2 ]))
1118
+ exp = PeriodIndex (['2010-10' , '2010-12' , 'NaT' , '2011-06' ],
1119
+ freq = 'M' , name = 'idx' )
1120
+ self ._check (idx , f , exp )
1139
1121
1140
1122
def test_pi_ops_offset (self ):
1141
1123
idx = PeriodIndex (['2011-01-01' , '2011-02-01' , '2011-03-01' ,
0 commit comments