-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
PROPOSAL: use datetime64 and timedelta64 to eval #22063
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 3 commits
6c33b65
7ff27d2
98bd79a
0c90051
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,22 @@ def np_array_datetime64_compat(arr, *args, **kwargs): | |
return np.array(arr, *args, **kwargs) | ||
|
||
|
||
# np.percentile should support datetime64 in upsteam. numpy/numpy#11620 | ||
# TODO: change the version if the bug fixed | ||
if _nlv >= '99.99.99': | ||
np_percentile_compat = np.percentile | ||
else: | ||
def np_percentile_compat(values, q, **kw): | ||
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. the iNat concern aside, this looks like a nice function. But I don't see why it should be in compat. Might make more sense in nanops? |
||
''' | ||
provide compat for np.percentile supporting datetime64 | ||
''' | ||
if values.dtype.kind == 'M': | ||
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. Does timedelta64 get handled correctly by numpy? |
||
result = np.percentile(values.view('i8'), q, **kw) | ||
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. Will this handle iNaT correctly? |
||
return result.astype(values.dtype) | ||
else: | ||
return np.percentile(values, q, **kw) | ||
|
||
|
||
__all__ = ['np', | ||
'_np_version_under1p10', | ||
'_np_version_under1p11', | ||
|
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.
Is this just a placeholder for "distant future"?