@@ -269,14 +269,34 @@ def test_intersection(self, tz, sort):
269
269
assert result .freq is None
270
270
assert result .tz == expected .tz
271
271
272
- def test_intersection_empty (self ):
272
+ # parametrize over both anchored and non-anchored freqs, as they
273
+ # have different code paths
274
+ @pytest .mark .parametrize ("freq" , ["T" , "B" ])
275
+ def test_intersection_empty (self , tz_aware_fixture , freq ):
273
276
# empty same freq GH2129
274
- rng = date_range ("6/1/2000" , "6/15/2000" , freq = "T" )
277
+ tz = tz_aware_fixture
278
+ rng = date_range ("6/1/2000" , "6/15/2000" , freq = freq , tz = tz )
275
279
result = rng [0 :0 ].intersection (rng )
276
280
assert len (result ) == 0
281
+ assert result .freq == rng .freq
277
282
278
283
result = rng .intersection (rng [0 :0 ])
279
284
assert len (result ) == 0
285
+ assert result .freq == rng .freq
286
+
287
+ # no overlap GH#33604
288
+ result = rng [:3 ].intersection (rng [- 3 :])
289
+ tm .assert_index_equal (result , rng [:0 ])
290
+ if freq != "T" :
291
+ # We don't preserve freq on non-anchored offsets
292
+ assert result .freq == rng .freq
293
+
294
+ # swapped left and right
295
+ result = rng [- 3 :].intersection (rng [:3 ])
296
+ tm .assert_index_equal (result , rng [:0 ])
297
+ if freq != "T" :
298
+ # We don't preserve freq on non-anchored offsets
299
+ assert result .freq == rng .freq
280
300
281
301
def test_intersection_bug_1708 (self ):
282
302
from pandas import DateOffset
@@ -450,6 +470,7 @@ def test_intersection_bug(self):
450
470
b = bdate_range ("12/10/2011" , "12/20/2011" )
451
471
result = a .intersection (b )
452
472
tm .assert_index_equal (result , b )
473
+ assert result .freq == b .freq
453
474
454
475
def test_month_range_union_tz_pytz (self , sort ):
455
476
from pytz import timezone
@@ -527,3 +548,4 @@ def test_intersection_bug(self):
527
548
b = bdate_range ("12/10/2011" , "12/20/2011" , freq = "C" )
528
549
result = a .intersection (b )
529
550
tm .assert_index_equal (result , b )
551
+ assert result .freq == b .freq
0 commit comments