@@ -151,3 +151,56 @@ def test_timestamp_add_timedelta64_unit(self, other, expected_difference):
151
151
result = ts + other
152
152
valdiff = result .value - ts .value
153
153
assert valdiff == expected_difference
154
+
155
+ @pytest .mark .parametrize ("ts" , [Timestamp .now (), Timestamp .now ("utc" )])
156
+ @pytest .mark .parametrize (
157
+ "other" ,
158
+ [
159
+ 1 ,
160
+ np .int64 (1 ),
161
+ np .array ([1 , 2 ], dtype = np .int32 ),
162
+ np .array ([3 , 4 ], dtype = np .uint64 ),
163
+ ],
164
+ )
165
+ def test_add_int_no_freq_raises (self , ts , other ):
166
+ with pytest .raises (ValueError , match = "without freq" ):
167
+ ts + other
168
+ with pytest .raises (ValueError , match = "without freq" ):
169
+ other + ts
170
+
171
+ with pytest .raises (ValueError , match = "without freq" ):
172
+ ts - other
173
+ with pytest .raises (TypeError ):
174
+ other - ts
175
+
176
+ @pytest .mark .parametrize (
177
+ "ts" ,
178
+ [
179
+ Timestamp ("1776-07-04" , freq = "D" ),
180
+ Timestamp ("1776-07-04" , tz = "UTC" , freq = "D" ),
181
+ ],
182
+ )
183
+ @pytest .mark .parametrize (
184
+ "other" ,
185
+ [
186
+ 1 ,
187
+ np .int64 (1 ),
188
+ np .array ([1 , 2 ], dtype = np .int32 ),
189
+ np .array ([3 , 4 ], dtype = np .uint64 ),
190
+ ],
191
+ )
192
+ def test_add_int_with_freq (self , ts , other ):
193
+ with tm .assert_produces_warning (FutureWarning ):
194
+ result1 = ts + other
195
+ with tm .assert_produces_warning (FutureWarning ):
196
+ result2 = other + ts
197
+
198
+ assert np .all (result1 == result2 )
199
+
200
+ with tm .assert_produces_warning (FutureWarning ):
201
+ result = result1 - other
202
+
203
+ assert np .all (result == ts )
204
+
205
+ with pytest .raises (TypeError ):
206
+ other - ts
0 commit comments