Skip to content

Refactored pandas_timedelta_to_timedeltastruct #55999

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 10 commits into from
Mar 20, 2024

Conversation

WillAyd
Copy link
Member

@WillAyd WillAyd commented Nov 16, 2023

this mostly cuts down on copy paste, but also implements const where it can be done on some variables

@mroeschke mroeschke added Internals Related to non-user accessible pandas implementation Timedelta Timedelta data type labels Nov 16, 2023
out->us = 0;
out->ns = 0;
}
case (NPY_FR_D):
Copy link
Member

Choose a reason for hiding this comment

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

is there a reason why some cases are in parens and others are not?

Copy link
Member Author

Choose a reason for hiding this comment

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

No - not sure how the parentheses snuck in here. Will remove

Copy link
Member

Choose a reason for hiding this comment

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

LGTM once these are cleaned up (and green)

} else if (base == NPY_FR_ms) {
per_sec = 1000;
} else if (base == NPY_FR_us) {
per_sec = 1000000;
Copy link
Member

Choose a reason for hiding this comment

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

overlap with tslibs.dtypes.periods_per_second. probably not worth the hassle of de-duplicating

Copy link
Member Author

Choose a reason for hiding this comment

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

If we wanted to we could make that an inline function like:

inline npy_int64 per_sec_multiplier(NPY_DATETIMEUNIT base):
    switch base:
    case NPY_FR_s:
        return 1;
    case NPY_FR_ms:
        return 1000;
    ...

@jbrockmendel
Copy link
Member

Small question, otherwise looks like a nice cleanup

Copy link
Contributor

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label Jan 12, 2024
@WillAyd
Copy link
Member Author

WillAyd commented Mar 19, 2024

Sorry I let this slip - this should be reviewable now

@mroeschke mroeschke added this to the 3.0 milestone Mar 20, 2024
@mroeschke mroeschke merged commit eb55bca into pandas-dev:main Mar 20, 2024
46 checks passed
@mroeschke
Copy link
Member

Thanks @WillAyd

@WillAyd WillAyd deleted the refactor-pd-td-to-tds branch March 22, 2024 15:35
pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
* Refactored pandas_timedelta_to_timedeltastruct

* use generic macros

* Revert "use generic macros"

This reverts commit 29d115d.

* fix sign issue

* wextra fixes

* more wextra

* remove extraneous parantheses
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internals Related to non-user accessible pandas implementation Stale Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants