Skip to content

REF: de-duplicate code in libperiod #33491

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 18 commits into from
Apr 15, 2020
Merged

Conversation

jbrockmendel
Copy link
Member

discussed a few months ago, this gets rid of date_info_from_days_and_time and instead re-uses pandas_datetime_to_datetimestruct

@gfyoung gfyoung added Clean Refactor Internal refactoring of code labels Apr 12, 2020
subsecond_fraction = second - dts.sec
dts.us = int((subsecond_fraction) * 1e6)
dts.ps = int(((subsecond_fraction) * 1e6 - dts.us) * 1e6)
if freq == FR_US:
Copy link
Contributor

Choose a reason for hiding this comment

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

elif on these?

Copy link
Member Author

Choose a reason for hiding this comment

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

updated+green

@jbrockmendel
Copy link
Member Author

cc @WillAyd trying to figure out which of the current CI failures are false-positives, is this one from Travis a real problem?

pandas/_libs/tslibs/period.c:9227:11: error: ‘__pyx_v_factor’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

   __pyx_r = (__pyx_v_sub * __pyx_v_factor);

           ^

pandas/_libs/tslibs/period.c:8995:26: note: ‘__pyx_v_factor’ was declared here

   __pyx_t_5numpy_int64_t __pyx_v_factor;

                          ^

cc1: all warnings being treated as errors

building 'pandas._libs.tslibs.resolution' extension

@WillAyd
Copy link
Member

WillAyd commented Apr 14, 2020

I'm assuming your latest commit fixes the issue, but yea I think just telling you that factor could potentially be uninitialized if none of the conditions branch, so either need to guarantee it branches or initialize to a value


date_info_from_days_and_time(dts, unix_date, abstime)
dt64_to_dtstruct(nanos, &dts2)
dts.hour = dts2.hour
Copy link
Member

Choose a reason for hiding this comment

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

Any reason you don't just pass the reference to dts in the call above?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because the caller might still need dts

Copy link
Member

Choose a reason for hiding this comment

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

Doesn't calling dt64_to_dtstruct do exactly what the next 5 lines of code do anyway?

Copy link
Member Author

Choose a reason for hiding this comment

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

i can confirm that just passing dts does Break The World. IIRC part of whats going on here is that dts may be out of bounds for dt64[ns]

Copy link
Member

Choose a reason for hiding this comment

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

Ah OK. Thanks for checking - seems strange to have to do this but probably a separate issue then

@jreback jreback added this to the 1.1 milestone Apr 15, 2020
@jreback jreback merged commit 577de1c into pandas-dev:master Apr 15, 2020
@jbrockmendel jbrockmendel deleted the per-nanos branch April 15, 2020 19:38
CloseChoice pushed a commit to CloseChoice/pandas that referenced this pull request Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants