-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
handle NaT add/sub in one place #19903
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
Conversation
nanos = delta_to_nanoseconds(other) | ||
offset_nanos = delta_to_nanoseconds(offset) | ||
if (nanos % offset_nanos).all() == 0: | ||
return nanos // offset_nanos |
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.
This block is never reached b/c there is a separate check for np.ndarray before this.
Codecov Report
@@ Coverage Diff @@
## master #19903 +/- ##
==========================================
+ Coverage 91.66% 91.67% +<.01%
==========================================
Files 150 150
Lines 48969 48967 -2
==========================================
+ Hits 44886 44889 +3
+ Misses 4083 4078 -5
Continue to review full report at Codecov.
|
thanks |
ATM DatetimeIndex/TimedeltaIndex/PeriodIndex each have special-casing for addition/subtraction of NaT. This checks for NaT up-front and puts all of that logic into add_nat and sub_nat methods.
Also makes another step towards centralizing all of the wrapping of the add/sub ops at the end of
__add__
and__sub__
.Should be orthogonal to other outstanding PRs, albeit just barely.