@@ -70,9 +70,8 @@ def test_parr_cmp_period_scalar(self, freq, box):
70
70
tm .assert_equal (per >= base , exp )
71
71
72
72
@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 ):
74
74
# GH#13200
75
- box = box_df_fail
76
75
xbox = np .ndarray if box is pd .Index else box
77
76
78
77
base = PeriodIndex (['2011-01' , '2011-02' , '2011-03' , '2011-04' ],
@@ -108,11 +107,9 @@ def test_parr_cmp_pi(self, freq, box_df_fail):
108
107
tm .assert_equal (base <= idx , exp )
109
108
110
109
@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 ):
112
111
# GH#13200
113
112
# different base freq
114
- box = box_df_fail
115
-
116
113
base = PeriodIndex (['2011-01' , '2011-02' , '2011-03' , '2011-04' ],
117
114
freq = freq )
118
115
base = tm .box_expected (base , box )
@@ -302,9 +299,7 @@ class TestPeriodIndexArithmetic(object):
302
299
# PeriodIndex - other is defined for integers, timedelta-like others,
303
300
# and PeriodIndex (with matching freq)
304
301
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 ):
308
303
rng = pd .period_range ('1/1/2000' , freq = 'D' , periods = 5 )
309
304
other = pd .period_range ('1/6/2000' , freq = 'D' , periods = 5 )
310
305
# TODO: parametrize over boxes for other?
@@ -346,9 +341,7 @@ def test_pi_sub_pi_with_nat(self):
346
341
expected = pd .Index ([pd .NaT , 0 * off , 0 * off , 0 * off , 0 * off ])
347
342
tm .assert_index_equal (result , expected )
348
343
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 ):
352
345
rng = pd .period_range ('1/1/2000' , freq = 'D' , periods = 5 )
353
346
other = pd .period_range ('1/6/2000' , freq = 'H' , periods = 5 )
354
347
# TODO: parametrize over boxes for other?
@@ -364,9 +357,6 @@ def test_parr_sub_pi_mismatched_freq(self, box_df_broadcast_failure):
364
357
@pytest .mark .parametrize ('op' , [operator .add , ops .radd ,
365
358
operator .sub , ops .rsub ])
366
359
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
-
370
360
dti = pd .DatetimeIndex (['2011-01-01' , '2011-01-02' ], freq = 'D' )
371
361
pi = dti .to_period ('D' )
372
362
pi = tm .box_expected (pi , box )
@@ -563,15 +553,18 @@ def test_pi_sub_isub_offset(self):
563
553
rng -= pd .offsets .MonthEnd (5 )
564
554
tm .assert_index_equal (rng , expected )
565
555
566
- def test_pi_add_offset_n_gt1 (self , box ):
556
+ def test_pi_add_offset_n_gt1 (self , box_transpose_fail ):
567
557
# GH#23215
568
558
# add offset to PeriodIndex with freq.n > 1
559
+ box , transpose = box_transpose_fail
560
+
569
561
per = pd .Period ('2016-01' , freq = '2M' )
570
562
pi = pd .PeriodIndex ([per ])
571
563
572
564
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 )
575
568
576
569
result = pi + per .freq
577
570
tm .assert_equal (result , expected )
@@ -582,12 +575,14 @@ def test_pi_add_offset_n_gt1(self, box):
582
575
def test_pi_add_offset_n_gt1_not_divisible (self , box_with_period ):
583
576
# GH#23215
584
577
# PeriodIndex with freq.n > 1 add offset with offset.n % freq.n != 0
578
+ box = box_with_period
585
579
586
580
pi = pd .PeriodIndex (['2016-01' ], freq = '2M' )
587
- pi = tm .box_expected (pi , box_with_period )
588
-
589
581
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 )
591
586
592
587
result = pi + to_offset ('3M' )
593
588
tm .assert_equal (result , expected )
@@ -801,14 +796,16 @@ def test_pi_add_sub_timedeltalike_freq_mismatch_monthly(self,
801
796
with pytest .raises (period .IncompatibleFrequency , match = msg ):
802
797
rng -= other
803
798
804
- def test_parr_add_sub_td64_nat (self , box ):
799
+ def test_parr_add_sub_td64_nat (self , box_transpose_fail ):
805
800
# GH#23320 special handling for timedelta64("NaT")
801
+ box , transpose = box_transpose_fail
802
+
806
803
pi = pd .period_range ("1994-04-01" , periods = 9 , freq = "19D" )
807
804
other = np .timedelta64 ("NaT" )
808
805
expected = pd .PeriodIndex (["NaT" ] * 9 , freq = "19D" )
809
806
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 )
812
809
813
810
result = obj + other
814
811
tm .assert_equal (result , expected )
0 commit comments