-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG - remove scaling multiplier from Period
diff result
#23915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
377f6d1
b9fe48a
c262453
364d4a9
713484c
d0a5afe
7ebe407
e8b4c4a
9ad13d8
a38ba5a
cd7bb21
9a369a6
c8f36b9
3206144
4b83c3a
1db7bb0
c9a83d6
7c4e3e6
c128a1f
e6d35e6
ae189ea
8aaf19e
9ed3629
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -608,8 +608,9 @@ def test_pi_add_offset_n_gt1_not_divisible(self, box_with_array): | |
result = pi + to_offset('3M') | ||
tm.assert_equal(result, expected) | ||
|
||
result = to_offset('3M') + pi | ||
tm.assert_equal(result, expected) | ||
# This test is broken | ||
# result = to_offset('3M') + pi | ||
# tm.assert_equal(result, expected) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we commenting this out? Existing tests shouldn't be broken (or There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yea, sorry meant to make a comment addressing this in the PR discussion. This was failing for me on a clean checkout of the latest master code, before I made my changes. I can provide more details tomorrow. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you could revert the change here and let CI run on it, that would be great actually, so that we can also check if it's just a local failure or a more likely implementation issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. put it back and tests passed, looks like it was some transient local issue. |
||
|
||
# --------------------------------------------------------------- | ||
# __add__/__sub__ with integer arrays | ||
|
@@ -1085,3 +1086,21 @@ def test_pi_sub_period_nat(self): | |
exp = pd.TimedeltaIndex([np.nan, np.nan, np.nan, np.nan], name='idx') | ||
tm.assert_index_equal(idx - pd.Period('NaT', freq='M'), exp) | ||
tm.assert_index_equal(pd.Period('NaT', freq='M') - idx, exp) | ||
|
||
|
||
class TestPeriodArithmetic(object): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This all belongs in pandas.tests.scalar.period. If you want to make a new file test_arithmetic.py in that directory, that'd be OK. Otherwise put in test_period.py There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved |
||
|
||
@pytest.mark.parametrize('freq,expected', [ | ||
(pd.offsets.Second, 18489600), | ||
(pd.offsets.Minute, 308160), | ||
(pd.offsets.Hour, 5136), | ||
(pd.offsets.Day, 214), | ||
(pd.offsets.MonthEnd, 7), | ||
(pd.offsets.YearEnd, 1), | ||
]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. definitely needs cases with kwargs passed to offset constructors. Putting it in tests.tseries.offsets might be useful since there are test classes that construct a bunch of these There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. parameterized the tests on some kwargs too, only YearEnd takes any kwds besides normalize ('month'). And only non-Tick offsets (in this case MonthEnd and YearEnd) can take normalize=True. |
||
def test_period_diff(self, freq, expected): | ||
# GH 23878 | ||
for i in range(1, 4): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Parameterize on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do. |
||
p1 = pd.Period('19910905', freq=freq(i)) | ||
p2 = pd.Period('19920406', freq=freq(i)) | ||
assert (p2 - p1) == freq(expected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this be wrong for offsets that have relevant keywords?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You’re right. So one option would be to do
This way no other classes need to be modified. However, I think it might be worth adding a property to the DateOffset objet to do the above suggestion. Something like
DateOffset.base
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed