@@ -730,11 +730,12 @@ def test_pi_ops(self):
730
730
731
731
self ._check (idx + 2 , lambda x : x - 2 , idx )
732
732
result = idx - Period ('2011-01' , freq = 'M' )
733
- exp = pd .Index ([0 , 1 , 2 , 3 ], name = 'idx' )
733
+ off = idx .freq
734
+ exp = pd .Index ([0 * off , 1 * off , 2 * off , 3 * off ], name = 'idx' )
734
735
tm .assert_index_equal (result , exp )
735
736
736
737
result = Period ('2011-01' , freq = 'M' ) - idx
737
- exp = pd .Index ([0 , - 1 , - 2 , - 3 ], name = 'idx' )
738
+ exp = pd .Index ([0 * off , - 1 * off , - 2 * off , - 3 * off ], name = 'idx' )
738
739
tm .assert_index_equal (result , exp )
739
740
740
741
@pytest .mark .parametrize ('ng' , ["str" , 1.5 ])
@@ -864,14 +865,15 @@ def test_pi_sub_period(self):
864
865
freq = 'M' , name = 'idx' )
865
866
866
867
result = idx - pd .Period ('2012-01' , freq = 'M' )
867
- exp = pd .Index ([- 12 , - 11 , - 10 , - 9 ], name = 'idx' )
868
+ off = idx .freq
869
+ exp = pd .Index ([- 12 * off , - 11 * off , - 10 * off , - 9 * off ], name = 'idx' )
868
870
tm .assert_index_equal (result , exp )
869
871
870
872
result = np .subtract (idx , pd .Period ('2012-01' , freq = 'M' ))
871
873
tm .assert_index_equal (result , exp )
872
874
873
875
result = pd .Period ('2012-01' , freq = 'M' ) - idx
874
- exp = pd .Index ([12 , 11 , 10 , 9 ], name = 'idx' )
876
+ exp = pd .Index ([12 * off , 11 * off , 10 * off , 9 * off ], name = 'idx' )
875
877
tm .assert_index_equal (result , exp )
876
878
877
879
result = np .subtract (pd .Period ('2012-01' , freq = 'M' ), idx )
@@ -898,11 +900,12 @@ def test_pi_sub_period_nat(self):
898
900
freq = 'M' , name = 'idx' )
899
901
900
902
result = idx - pd .Period ('2012-01' , freq = 'M' )
901
- exp = pd .Index ([- 12 , np .nan , - 10 , - 9 ], name = 'idx' )
903
+ off = idx .freq
904
+ exp = pd .Index ([- 12 * off , pd .NaT , - 10 * off , - 9 * off ], name = 'idx' )
902
905
tm .assert_index_equal (result , exp )
903
906
904
907
result = pd .Period ('2012-01' , freq = 'M' ) - idx
905
- exp = pd .Index ([12 , np . nan , 10 , 9 ], name = 'idx' )
908
+ exp = pd .Index ([12 * off , pd . NaT , 10 * off , 9 * off ], name = 'idx' )
906
909
tm .assert_index_equal (result , exp )
907
910
908
911
exp = pd .TimedeltaIndex ([np .nan , np .nan , np .nan , np .nan ], name = 'idx' )
0 commit comments