-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Implement mul, floordiv, mod, divmod, and reversed directly in TimedeltaArray #23885
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 1 commit
2f75de9
749cfed
1515e21
d7c727c
8ae9059
2577ee6
62d2018
8f7b7b4
6d162d8
ef25750
bc5a3d6
700c5a2
d7591b6
bdb27ec
87f36ac
987eecd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -447,6 +447,7 @@ def __floordiv__(self, other): | |
if isinstance(other, (ABCSeries, ABCDataFrame, ABCIndexClass)): | ||
return NotImplemented | ||
|
||
other = lib.item_from_zerodim(other) | ||
if is_scalar(other): | ||
if isinstance(other, (timedelta, np.timedelta64, Tick)): | ||
other = Timedelta(other) | ||
|
@@ -509,6 +510,7 @@ def __rfloordiv__(self, other): | |
if isinstance(other, (ABCSeries, ABCDataFrame, ABCIndexClass)): | ||
return NotImplemented | ||
|
||
other = lib.item_from_zerodim(other) | ||
if is_scalar(other): | ||
if isinstance(other, (timedelta, np.timedelta64, Tick)): | ||
other = Timedelta(other) | ||
|
@@ -558,6 +560,8 @@ def __mod__(self, other): | |
# Note: This is a naive implementation, can likely be optimized | ||
if isinstance(other, (ABCSeries, ABCDataFrame, ABCIndexClass)): | ||
return NotImplemented | ||
|
||
other = lib.item_from_zerodim(other) | ||
if isinstance(other, (timedelta, np.timedelta64, Tick)): | ||
other = Timedelta(other) | ||
return self - (self // other) * other | ||
|
@@ -566,6 +570,8 @@ def __rmod__(self, other): | |
# Note: This is a naive implementation, can likely be optimized | ||
if isinstance(other, (ABCSeries, ABCDataFrame, ABCIndexClass)): | ||
return NotImplemented | ||
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 this share with 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. Not really. For div and divmod either timedeltas or numeric are valid. For reversed ops only timedeltas are valid. |
||
|
||
other = lib.item_from_zerodim(other) | ||
if isinstance(other, (timedelta, np.timedelta64, Tick)): | ||
other = Timedelta(other) | ||
return other - (other // self) * self | ||
|
@@ -574,6 +580,8 @@ def __divmod__(self, other): | |
# Note: This is a naive implementation, can likely be optimized | ||
if isinstance(other, (ABCSeries, ABCDataFrame, ABCIndexClass)): | ||
return NotImplemented | ||
|
||
other = lib.item_from_zerodim(other) | ||
if isinstance(other, (timedelta, np.timedelta64, Tick)): | ||
other = Timedelta(other) | ||
|
||
|
@@ -585,6 +593,8 @@ def __rdivmod__(self, other): | |
# Note: This is a naive implementation, can likely be optimized | ||
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 this share with |
||
if isinstance(other, (ABCSeries, ABCDataFrame, ABCIndexClass)): | ||
return NotImplemented | ||
|
||
other = lib.item_from_zerodim(other) | ||
if isinstance(other, (timedelta, np.timedelta64, Tick)): | ||
other = Timedelta(other) | ||
|
||
|
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.
can this share with floordiv?