@@ -269,14 +269,34 @@ def test_intersection(self, tz, sort):
269269 assert result .freq is None
270270 assert result .tz == expected .tz
271271
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 ):
273276 # 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 )
275279 result = rng [0 :0 ].intersection (rng )
276280 assert len (result ) == 0
281+ assert result .freq == rng .freq
277282
278283 result = rng .intersection (rng [0 :0 ])
279284 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
280300
281301 def test_intersection_bug_1708 (self ):
282302 from pandas import DateOffset
@@ -450,6 +470,7 @@ def test_intersection_bug(self):
450470 b = bdate_range ("12/10/2011" , "12/20/2011" )
451471 result = a .intersection (b )
452472 tm .assert_index_equal (result , b )
473+ assert result .freq == b .freq
453474
454475 def test_month_range_union_tz_pytz (self , sort ):
455476 from pytz import timezone
@@ -527,3 +548,4 @@ def test_intersection_bug(self):
527548 b = bdate_range ("12/10/2011" , "12/20/2011" , freq = "C" )
528549 result = a .intersection (b )
529550 tm .assert_index_equal (result , b )
551+ assert result .freq == b .freq
0 commit comments