@@ -384,28 +384,6 @@ def test_union(self):
384
384
385
385
def test_add_iadd (self ):
386
386
for tz in self .tz :
387
- rng1 = pd .date_range ('1/1/2000' , freq = 'D' , periods = 5 , tz = tz )
388
- other1 = pd .date_range ('1/6/2000' , freq = 'D' , periods = 5 , tz = tz )
389
- expected1 = pd .date_range ('1/1/2000' , freq = 'D' , periods = 10 , tz = tz )
390
-
391
- rng2 = pd .date_range ('1/1/2000' , freq = 'D' , periods = 5 , tz = tz )
392
- other2 = pd .date_range ('1/4/2000' , freq = 'D' , periods = 5 , tz = tz )
393
- expected2 = pd .date_range ('1/1/2000' , freq = 'D' , periods = 8 , tz = tz )
394
-
395
- rng3 = pd .date_range ('1/1/2000' , freq = 'D' , periods = 5 , tz = tz )
396
- other3 = pd .DatetimeIndex ([], tz = tz )
397
- expected3 = pd .date_range ('1/1/2000' , freq = 'D' , periods = 5 , tz = tz )
398
-
399
- for rng , other , expected in [(rng1 , other1 , expected1 ),
400
- (rng2 , other2 , expected2 ),
401
- (rng3 , other3 , expected3 )]:
402
- # previously performed setop (deprecated in 0.16.0), now
403
- # raises TypeError (GH14164)
404
- with tm .assertRaises (TypeError ):
405
- rng + other
406
-
407
- with tm .assertRaises (TypeError ):
408
- rng += other
409
387
410
388
# offset
411
389
offsets = [pd .offsets .Hour (2 ), timedelta (hours = 2 ),
@@ -457,7 +435,7 @@ def test_add_dti_dti(self):
457
435
with tm .assertRaises (TypeError ):
458
436
dti + dti_tz
459
437
460
- def test_diff (self ):
438
+ def test_difference (self ):
461
439
for tz in self .tz :
462
440
# diff
463
441
rng1 = pd .date_range ('1/1/2000' , freq = 'D' , periods = 5 , tz = tz )
@@ -529,10 +507,15 @@ def test_sub_dti_dti(self):
529
507
with tm .assertRaises (TypeError ):
530
508
dti_tz - dti_tz2
531
509
510
+ # isub
511
+ dti -= dti
512
+ tm .assert_index_equal (dti , expected )
513
+
532
514
# different length raises ValueError
515
+ dti1 = date_range ('20130101' , periods = 3 )
533
516
dti2 = date_range ('20130101' , periods = 4 )
534
517
with tm .assertRaises (ValueError ):
535
- dti - dti2
518
+ dti1 - dti2
536
519
537
520
# NaN propagation
538
521
dti1 = DatetimeIndex (['2012-01-01' , np .nan , '2012-01-03' ])
@@ -2036,7 +2019,7 @@ def test_resolution(self):
2036
2019
idx = pd .period_range (start = '2013-04-01' , periods = 30 , freq = freq )
2037
2020
self .assertEqual (idx .resolution , expected )
2038
2021
2039
- def test_add_iadd (self ):
2022
+ def test_union (self ):
2040
2023
# union
2041
2024
rng1 = pd .period_range ('1/1/2000' , freq = 'D' , periods = 5 )
2042
2025
other1 = pd .period_range ('1/6/2000' , freq = 'D' , periods = 5 )
@@ -2062,7 +2045,8 @@ def test_add_iadd(self):
2062
2045
rng5 = pd .PeriodIndex (['2000-01-01 09:01' , '2000-01-01 09:03' ,
2063
2046
'2000-01-01 09:05' ], freq = 'T' )
2064
2047
other5 = pd .PeriodIndex (['2000-01-01 09:01' , '2000-01-01 09:05'
2065
- '2000-01-01 09:08' ], freq = 'T' )
2048
+ '2000-01-01 09:08' ],
2049
+ freq = 'T' )
2066
2050
expected5 = pd .PeriodIndex (['2000-01-01 09:01' , '2000-01-01 09:03' ,
2067
2051
'2000-01-01 09:05' , '2000-01-01 09:08' ],
2068
2052
freq = 'T' )
@@ -2083,18 +2067,19 @@ def test_add_iadd(self):
2083
2067
expected6 ),
2084
2068
(rng7 , other7 , expected7 )]:
2085
2069
2086
- # GH9094
2087
- with tm .assertRaises (TypeError ):
2088
- rng + other
2089
-
2090
2070
result_union = rng .union (other )
2091
-
2092
2071
tm .assert_index_equal (result_union , expected )
2093
2072
2094
- # GH 6527
2095
- # GH9094
2096
- with tm .assertRaises (TypeError ):
2097
- rng += other
2073
+ def test_add_iadd (self ):
2074
+ rng = pd .period_range ('1/1/2000' , freq = 'D' , periods = 5 )
2075
+ other = pd .period_range ('1/6/2000' , freq = 'D' , periods = 5 )
2076
+
2077
+ # previously performed setop union, now raises TypeError (GH14164)
2078
+ with tm .assertRaises (TypeError ):
2079
+ rng + other
2080
+
2081
+ with tm .assertRaises (TypeError ):
2082
+ rng += other
2098
2083
2099
2084
# offset
2100
2085
# DateOffset
@@ -2181,7 +2166,7 @@ def test_add_iadd(self):
2181
2166
rng += 1
2182
2167
tm .assert_index_equal (rng , expected )
2183
2168
2184
- def test_sub_isub (self ):
2169
+ def test_difference (self ):
2185
2170
# diff
2186
2171
rng1 = pd .period_range ('1/1/2000' , freq = 'D' , periods = 5 )
2187
2172
other1 = pd .period_range ('1/6/2000' , freq = 'D' , periods = 5 )
@@ -2223,6 +2208,19 @@ def test_sub_isub(self):
2223
2208
result_union = rng .difference (other )
2224
2209
tm .assert_index_equal (result_union , expected )
2225
2210
2211
+ def test_sub_isub (self ):
2212
+
2213
+ # previously performed setop, now raises TypeError (GH14164)
2214
+ # TODO needs to wait on #13077 for decision on result type
2215
+ rng = pd .period_range ('1/1/2000' , freq = 'D' , periods = 5 )
2216
+ other = pd .period_range ('1/6/2000' , freq = 'D' , periods = 5 )
2217
+
2218
+ with tm .assertRaises (TypeError ):
2219
+ rng - other
2220
+
2221
+ with tm .assertRaises (TypeError ):
2222
+ rng -= other
2223
+
2226
2224
# offset
2227
2225
# DateOffset
2228
2226
rng = pd .period_range ('2014' , '2024' , freq = 'A' )
0 commit comments