-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ERR: Clarify exceptions for invalid datetimelike operations #17772
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 5 commits
236122a
708d1f8
3afe6b5
957b79f
435a9b3
1f78070
4a69723
2014d30
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 |
---|---|---|
|
@@ -434,30 +434,53 @@ def test_add_iadd(self): | |
tm.assert_index_equal(rng, expected) | ||
|
||
idx = DatetimeIndex(['2011-01-01', '2011-01-02']) | ||
msg = "cannot add a datelike to a DatetimeIndex" | ||
msg = "cannot add DatetimeIndex and Timestamp" | ||
with tm.assert_raises_regex(TypeError, msg): | ||
idx + Timestamp('2011-01-01') | ||
|
||
with tm.assert_raises_regex(TypeError, msg): | ||
Timestamp('2011-01-01') + idx | ||
|
||
def test_add_dti_ts(self): | ||
dti = DatetimeIndex(['2011-01-01', '2011-01-02']) | ||
ts = Timestamp('2011-01-01') | ||
msg = 'cannot add DatetimeIndex and Timestamp' | ||
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 combine these into a single tests and use parametrize for the args |
||
|
||
with tm.assert_raises_regex(TypeError, msg): | ||
dti + ts | ||
|
||
with tm.assert_raises_regex(TypeError, msg): | ||
ts + dti | ||
|
||
def test_add_dti_dt64(self): | ||
dti = DatetimeIndex(['2011-01-01', '2011-01-02']) | ||
dt64 = np.datetime64('2005-02-25') | ||
msg = 'cannot add DatetimeIndex and datetime64' | ||
|
||
with tm.assert_raises_regex(TypeError, msg): | ||
dti + dt64 | ||
|
||
with tm.assert_raises_regex(TypeError, msg): | ||
dt64 + dti | ||
|
||
def test_add_dti_dti(self): | ||
# previously performed setop (deprecated in 0.16.0), now raises | ||
# TypeError (GH14164) | ||
|
||
dti = date_range('20130101', periods=3) | ||
dti_tz = date_range('20130101', periods=3).tz_localize('US/Eastern') | ||
msg = 'cannot add DatetimeIndex and DatetimeIndex' | ||
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 u parametrize this as well |
||
|
||
with pytest.raises(TypeError): | ||
with tm.assert_raises_regex(TypeError, msg): | ||
dti + dti | ||
|
||
with pytest.raises(TypeError): | ||
with tm.assert_raises_regex(TypeError, msg): | ||
dti_tz + dti_tz | ||
|
||
with pytest.raises(TypeError): | ||
with tm.assert_raises_regex(TypeError, msg): | ||
dti_tz + dti | ||
|
||
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. hmm I think you removed the |
||
with pytest.raises(TypeError): | ||
with tm.assert_raises_regex(TypeError, msg): | ||
dti + dti_tz | ||
|
||
def test_difference(self): | ||
|
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.
add the issue number as a comment