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

Conversation

Projects
None yet
2 participants
@jbrockmendel
Member

jbrockmendel commented Feb 25, 2018

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.

@jreback

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):

This comment has been minimized.

@jreback

jreback Feb 25, 2018

Contributor

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

This comment has been minimized.

@jbrockmendel

jbrockmendel Feb 26, 2018

Member

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):

This comment has been minimized.

@jreback

jreback Feb 25, 2018

Contributor

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]))

This comment has been minimized.

@jreback

jreback Feb 25, 2018

Contributor

is this an api change?

This comment has been minimized.

@jbrockmendel

jbrockmendel Feb 26, 2018

Member

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

@codecov

This comment has been minimized.

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

3 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@jreback

This comment has been minimized.

Contributor

jreback commented Feb 26, 2018

thanks!

harisbal pushed a commit to harisbal/pandas that referenced this pull request Feb 28, 2018

@jbrockmendel jbrockmendel deleted the jbrockmendel:cmpops branch Jun 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment