Skip to content
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

cleanup order of operations kludges #19895

Merged
merged 2 commits into from
Feb 26, 2018
Merged

Conversation

jbrockmendel
Copy link
Member

DatetimeIndexOpsMixin has an unfortunate kludge where it checks if self is a TimedeltaIndex and if so dispatches to a reversed operation. This then makes subsequent checks less straightforward than they could/should be. This fixes that.

This is in preparation for separating out DatetimeArray/TimedeltaArray/PeriodArray, so this uses formatting on error messages to be class-agnostic.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

always rebase on master, the pyarrow issue was resolved yesterday

@@ -864,11 +864,18 @@ def _add_datelike(self, other):
def _sub_datelike(self, other):
# subtract a datetime from myself, yielding a TimedeltaIndex
from pandas import TimedeltaIndex

if isinstance(other, np.ndarray):
Copy link
Contributor

Choose a reason for hiding this comment

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

why don't you do this in 873, and just always wrap it

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good.

@@ -416,9 +414,15 @@ def _evaluate_with_timedelta_like(self, other, op):
def _add_datelike(self, other):
# adding a timedeltaindex to a datetimelike
from pandas import Timestamp, DatetimeIndex
if isinstance(other, np.ndarray):
Copy link
Contributor

Choose a reason for hiding this comment

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

same

@@ -792,7 +792,7 @@ def test_addition_ops(self):
pytest.raises(ValueError, lambda: tdi[0:1] + dti)

# random indexes
pytest.raises(TypeError, lambda: tdi + Int64Index([1, 2, 3]))
Copy link
Contributor

Choose a reason for hiding this comment

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

is this an api change?

Copy link
Member Author

Choose a reason for hiding this comment

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

not sure if it counts as api change or bugfix. The error currently being raises is incorrect.

@jreback jreback added Datetime Datetime data dtype Clean labels Feb 25, 2018
@codecov
Copy link

codecov bot commented Feb 26, 2018

Codecov Report

Merging #19895 into master will decrease coverage by <.01%.
The diff coverage is 91.3%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #19895      +/-   ##
==========================================
- Coverage   91.67%   91.66%   -0.01%     
==========================================
  Files         150      150              
  Lines       48936    48930       -6     
==========================================
- Hits        44860    44853       -7     
- Misses       4076     4077       +1
Flag Coverage Δ
#multiple 90.04% <91.3%> (-0.01%) ⬇️
#single 41.82% <34.78%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/indexes/timedeltas.py 91.21% <100%> (+0.21%) ⬆️
pandas/core/indexes/datetimes.py 95.61% <75%> (ø) ⬆️
pandas/core/indexes/datetimelike.py 97.33% <88.88%> (-0.06%) ⬇️
pandas/core/dtypes/cast.py 87.68% <0%> (-0.3%) ⬇️

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 8f1dfa7...e34c4a5. Read the comment docs.

@jreback jreback added this to the 0.23.0 milestone Feb 26, 2018
@jreback jreback merged commit f105cdf into pandas-dev:master Feb 26, 2018
@jreback
Copy link
Contributor

jreback commented Feb 26, 2018

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Datetime Datetime data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants