-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: implement Timedelta._as_unit #47162
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
@@ -954,7 +954,7 @@ void pandas_timedelta_to_timedeltastruct(npy_timedelta td, | |||
case NPY_FR_s: | |||
// special case where we can simplify many expressions bc per_sec=1 | |||
|
|||
per_day = 86400000LL; | |||
per_day = 86400LL; |
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.
Did this fix a bug somewhere?
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.
turns out not to be relevant, could actually get rid of per_day here entirely
assert rt.value == td.value | ||
assert rt._reso == td._reso | ||
|
||
def test_as_unit_overflows(self): |
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.
Just confirming aloud, based on the multiplication operation we can't get to a state where underflowing occurs (and therefore can't test that)?
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 is all in integers, so i dont think underflows are an issue
td._as_unit("ms", round_ok=False) | ||
|
||
def test_as_unit_non_nano(self): | ||
# case where we are going neither to nor from nano |
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.
Not really sure what neither to nor
means (if it's an idiom)
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.
"not to nano" and "not from nano"
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.
So _as_unit
will be used separately from _as_reso
in the future?
Yes _as_unit is the one that will eventually be user-facing. Just didnt want to make it public yet in case we want to change the name |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.