Skip to content

Implement get_supported_reso #48956

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

Merged
merged 1 commit into from
Oct 5, 2022
Merged

Conversation

jbrockmendel
Copy link
Member

I find myself implementing this in a bunch of branches, so splitting it off into a separate PR.

cpdef NPY_DATETIMEUNIT get_supported_reso(NPY_DATETIMEUNIT reso):
# If we have an unsupported reso, return the nearest supported reso.
if reso == NPY_DATETIMEUNIT.NPY_FR_GENERIC:
# TODO: or raise ValueError? trying this gives unraisable errors, but
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I would support raising. I image this would cause silent failures. Okay to follow up

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative is to just return NPY_FR_GENERIC and have the caller check for it? Or I imagine other code paths would raise (albeit probably with not an entirely clear message)

@mroeschke mroeschke added the Non-Nano datetime64/timedelta64 with non-nanosecond resolution label Oct 5, 2022
@mroeschke mroeschke added this to the 1.6 milestone Oct 5, 2022
@mroeschke mroeschke merged commit 29f67d3 into pandas-dev:main Oct 5, 2022
@mroeschke
Copy link
Member

Thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the get_supported branch October 6, 2022 14:08
@mroeschke mroeschke modified the milestones: 1.6, 2.0 Oct 13, 2022
noatamir pushed a commit to noatamir/pandas that referenced this pull request Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Non-Nano datetime64/timedelta64 with non-nanosecond resolution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants