@@ -70,9 +70,8 @@ def test_parr_cmp_period_scalar(self, freq, box):
7070 tm .assert_equal (per >= base , exp )
7171
7272 @pytest .mark .parametrize ('freq' , ['M' , '2M' , '3M' ])
73- def test_parr_cmp_pi (self , freq , box_df_fail ):
73+ def test_parr_cmp_pi (self , freq , box ):
7474 # GH#13200
75- box = box_df_fail
7675 xbox = np .ndarray if box is pd .Index else box
7776
7877 base = PeriodIndex (['2011-01' , '2011-02' , '2011-03' , '2011-04' ],
@@ -108,11 +107,9 @@ def test_parr_cmp_pi(self, freq, box_df_fail):
108107 tm .assert_equal (base <= idx , exp )
109108
110109 @pytest .mark .parametrize ('freq' , ['M' , '2M' , '3M' ])
111- def test_parr_cmp_pi_mismatched_freq_raises (self , freq , box_df_fail ):
110+ def test_parr_cmp_pi_mismatched_freq_raises (self , freq , box ):
112111 # GH#13200
113112 # different base freq
114- box = box_df_fail
115-
116113 base = PeriodIndex (['2011-01' , '2011-02' , '2011-03' , '2011-04' ],
117114 freq = freq )
118115 base = tm .box_expected (base , box )
@@ -302,9 +299,7 @@ class TestPeriodIndexArithmetic(object):
302299 # PeriodIndex - other is defined for integers, timedelta-like others,
303300 # and PeriodIndex (with matching freq)
304301
305- def test_parr_add_iadd_parr_raises (self , box_df_broadcast_failure ):
306- box = box_df_broadcast_failure
307-
302+ def test_parr_add_iadd_parr_raises (self , box ):
308303 rng = pd .period_range ('1/1/2000' , freq = 'D' , periods = 5 )
309304 other = pd .period_range ('1/6/2000' , freq = 'D' , periods = 5 )
310305 # TODO: parametrize over boxes for other?
@@ -346,9 +341,7 @@ def test_pi_sub_pi_with_nat(self):
346341 expected = pd .Index ([pd .NaT , 0 * off , 0 * off , 0 * off , 0 * off ])
347342 tm .assert_index_equal (result , expected )
348343
349- def test_parr_sub_pi_mismatched_freq (self , box_df_broadcast_failure ):
350- box = box_df_broadcast_failure
351-
344+ def test_parr_sub_pi_mismatched_freq (self , box ):
352345 rng = pd .period_range ('1/1/2000' , freq = 'D' , periods = 5 )
353346 other = pd .period_range ('1/6/2000' , freq = 'H' , periods = 5 )
354347 # TODO: parametrize over boxes for other?
@@ -364,9 +357,6 @@ def test_parr_sub_pi_mismatched_freq(self, box_df_broadcast_failure):
364357 @pytest .mark .parametrize ('op' , [operator .add , ops .radd ,
365358 operator .sub , ops .rsub ])
366359 def test_pi_add_sub_float (self , op , other , box ):
367- if box is pd .DataFrame and isinstance (other , np .ndarray ):
368- pytest .xfail (reason = "Tries to broadcast incorrectly" )
369-
370360 dti = pd .DatetimeIndex (['2011-01-01' , '2011-01-02' ], freq = 'D' )
371361 pi = dti .to_period ('D' )
372362 pi = tm .box_expected (pi , box )
@@ -563,15 +553,18 @@ def test_pi_sub_isub_offset(self):
563553 rng -= pd .offsets .MonthEnd (5 )
564554 tm .assert_index_equal (rng , expected )
565555
566- def test_pi_add_offset_n_gt1 (self , box ):
556+ def test_pi_add_offset_n_gt1 (self , box_transpose_fail ):
567557 # GH#23215
568558 # add offset to PeriodIndex with freq.n > 1
559+ box , transpose = box_transpose_fail
560+
569561 per = pd .Period ('2016-01' , freq = '2M' )
570562 pi = pd .PeriodIndex ([per ])
571563
572564 expected = pd .PeriodIndex (['2016-03' ], freq = '2M' )
573- pi = tm .box_expected (pi , box )
574- expected = tm .box_expected (expected , box )
565+
566+ pi = tm .box_expected (pi , box , transpose = transpose )
567+ expected = tm .box_expected (expected , box , transpose = transpose )
575568
576569 result = pi + per .freq
577570 tm .assert_equal (result , expected )
@@ -582,12 +575,14 @@ def test_pi_add_offset_n_gt1(self, box):
582575 def test_pi_add_offset_n_gt1_not_divisible (self , box_with_period ):
583576 # GH#23215
584577 # PeriodIndex with freq.n > 1 add offset with offset.n % freq.n != 0
578+ box = box_with_period
585579
586580 pi = pd .PeriodIndex (['2016-01' ], freq = '2M' )
587- pi = tm .box_expected (pi , box_with_period )
588-
589581 expected = pd .PeriodIndex (['2016-04' ], freq = '2M' )
590- expected = tm .box_expected (expected , box_with_period )
582+
583+ # FIXME: with transposing these tests fail
584+ pi = tm .box_expected (pi , box , transpose = False )
585+ expected = tm .box_expected (expected , box , transpose = False )
591586
592587 result = pi + to_offset ('3M' )
593588 tm .assert_equal (result , expected )
@@ -801,14 +796,16 @@ def test_pi_add_sub_timedeltalike_freq_mismatch_monthly(self,
801796 with pytest .raises (period .IncompatibleFrequency , match = msg ):
802797 rng -= other
803798
804- def test_parr_add_sub_td64_nat (self , box ):
799+ def test_parr_add_sub_td64_nat (self , box_transpose_fail ):
805800 # GH#23320 special handling for timedelta64("NaT")
801+ box , transpose = box_transpose_fail
802+
806803 pi = pd .period_range ("1994-04-01" , periods = 9 , freq = "19D" )
807804 other = np .timedelta64 ("NaT" )
808805 expected = pd .PeriodIndex (["NaT" ] * 9 , freq = "19D" )
809806
810- obj = tm .box_expected (pi , box )
811- expected = tm .box_expected (expected , box )
807+ obj = tm .box_expected (pi , box , transpose = transpose )
808+ expected = tm .box_expected (expected , box , transpose = transpose )
812809
813810 result = obj + other
814811 tm .assert_equal (result , expected )
0 commit comments