-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
check for datetime+period addition #18524
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 1 commit
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 |
---|---|---|
|
@@ -1038,6 +1038,24 @@ def test_add_raises(self): | |
with tm.assert_raises_regex(TypeError, msg): | ||
dt1 + dt2 | ||
|
||
boxes = [lambda x: x, lambda x: pd.Series([x]), lambda x: pd.Index([x])] | ||
|
||
@pytest.mark.parametrize('lbox', boxes) | ||
@pytest.mark.parametrize('rbox', boxes) | ||
def test_add_timestamp_raises(self, rbox, lbox): | ||
# GH # 17983 | ||
ts = pd.Timestamp('2017') | ||
per = pd.Period('2017', freq='M') | ||
|
||
with pytest.raises(TypeError): | ||
lbox(ts) + rbox(per) | ||
|
||
with pytest.raises(TypeError): | ||
lbox(per) + rbox(ts) | ||
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. can you add a similar test with Series of periods & Timestamp; I think these are now in pandas/tests/series/test_timestamp.py IIRC (maybe make a test_period.py in series ok too). 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. woops, just pushed without addressing this. Do you mean a Series that mixed, contains both Periods and Timestamps? |
||
|
||
with pytest.raises(TypeError): | ||
lbox(per) + rbox(per) | ||
|
||
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. can you add similar tests for sub 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. OK for todo list? I'd like to keep this narrow, busy day ahead. 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. ok |
||
def test_sub(self): | ||
dt1 = Period('2011-01-01', freq='D') | ||
dt2 = Period('2011-01-15', freq='D') | ||
|
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.
Let's make sure that the right error message is hit (use
tm.assert_raises_regex
to be safe, unclear ATM whether we're going to leverage the most recentpytest
API).