Skip to content

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

Merged
merged 8 commits into from
Oct 8, 2017

Conversation

mturzanska
Copy link
Contributor

closes #9631

@mturzanska mturzanska changed the title Clarify exceptions for invalid datetimelike operations ERR: Clarify exceptions for invalid datetimelike operations Oct 3, 2017
@mturzanska
Copy link
Contributor Author

Seemed too small a change for a what's new note

@codecov
Copy link

codecov bot commented Oct 4, 2017

Codecov Report

Merging #17772 into master will decrease coverage by 0.01%.
The diff coverage is 75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #17772      +/-   ##
==========================================
- Coverage   91.26%   91.24%   -0.02%     
==========================================
  Files         163      163              
  Lines       49872    49976     +104     
==========================================
+ Hits        45514    45601      +87     
- Misses       4358     4375      +17
Flag Coverage Δ
#multiple 89.05% <75%> (ø) ⬆️
#single 40.24% <25%> (-0.06%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/datetimelike.py 97.09% <100%> (+0.2%) ⬆️
pandas/core/indexes/datetimes.py 95.58% <50%> (ø) ⬆️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/indexing.py 93% <0%> (-0.98%) ⬇️
pandas/core/series.py 94.89% <0%> (-0.16%) ⬇️
pandas/core/frame.py 97.74% <0%> (-0.09%) ⬇️
pandas/core/generic.py 92.03% <0%> (-0.09%) ⬇️
pandas/core/common.py 91.42% <0%> (ø) ⬆️
pandas/core/indexes/base.py 96.46% <0%> (ø) ⬆️
pandas/core/indexes/multi.py 96.39% <0%> (ø) ⬆️
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 81694dc...2014d30. Read the comment docs.

@jreback jreback added Error Reporting Incorrect or improved errors from pandas Datetime Datetime data dtype labels Oct 4, 2017
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'])
Copy link
Contributor

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

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'
Copy link
Contributor

Choose a reason for hiding this comment

The 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

@jreback
Copy link
Contributor

jreback commented Oct 4, 2017

some comments. ping when pushed and green. skipping whatsnew is fine.

@jreback jreback added this to the 0.21.0 milestone Oct 4, 2017
Combine multiple tests using parametrize
Add issue number in the comment
@mturzanska
Copy link
Contributor Author

@jreback addressed all comments, tests pass


with pytest.raises(TypeError):
dti_tz + dti

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm I think you removed the dti_tz + dti_tz tests (IOW a tz-aware interacting with a non-tzaware). these can be a separate test function. also add a datetime scalar addend.

Prettify test_add_dti_dti
Add datetime object to
test_add_datetimelike params
dti = date_range('20110101', periods=3)
combinations = product((dti_tz, dti), repeat=2)

msg = 'cannot add DatetimeIndex and DatetimeIndex'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can u parametrize this as well

@jreback jreback merged commit 6e81222 into pandas-dev:master Oct 8, 2017
@jreback
Copy link
Contributor

jreback commented Oct 8, 2017

thanks @mturzanska

ghost pushed a commit to reef-technologies/pandas that referenced this pull request Oct 16, 2017
alanbato pushed a commit to alanbato/pandas that referenced this pull request Nov 10, 2017
No-Stream pushed a commit to No-Stream/pandas that referenced this pull request Nov 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Error Reporting Incorrect or improved errors from pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ERR: clarify exceptions for invalid datetimelike ops
2 participants