-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
Remove duplicated logic from period_helper #19540
Conversation
Codecov Report
@@ Coverage Diff @@
## master #19540 +/- ##
=======================================
Coverage 91.62% 91.62%
=======================================
Files 150 150
Lines 48773 48773
=======================================
Hits 44687 44687
Misses 4086 4086
Continue to review full report at Codecov.
|
int get_yq(npy_int64 ordinal, int freq, int *quarter, int *year); | ||
int _quarter_year(npy_int64 ordinal, int freq, int *year, int *quarter); |
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 seems an odd naming convention
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.
Yah, _quarter_year is actually really redundant with get_yq, so they will be merged in the PR after next.
# period accessors | ||
|
||
ctypedef int (*accessor)(int64_t ordinal, int freq) except INT32_MIN | ||
|
||
|
||
cdef int pyear(int64_t ordinal, int freq): |
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.
these can be inline?
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.
get_accessor_func returns pointers to these functions. Does that affect inline-ability?
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.
no idea. ok can you run a perf comparison on period stuff, maybe even vs 0.21.0 so we can get a good sense if anything has changed much.
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.
The compiler didn't complain about the inlining. Looking at timeit results the difference is indistinguishable. Will get asv going in a few minutes.
return DtoB_weekday(absdate); | ||
} | ||
static npy_int64 DtoB(struct date_info *dinfo, int roll_back) { | ||
int day_of_week = dayofweek(dinfo->year, dinfo->month, dinfo->day); |
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.
assuming you are planning on removing these to cython as we likely already have routines that do exactly this (next PR)
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.
DtoB
actually stays in place at least through the next two PRs in this sequence. This PR is getting dayofweek
from the implementation in src/datetime/np_datetime, so did remove the duplicated routine in period_helper.
No change against master (running against ~0.21.0 now)
|
Against ~0.21
|
rebase as we merged the get_day function. lgtm otherwise. |
Once this goes in I can rebase #19550, then after that we'll get rid of date_info and just use pandas_datetimestruct directly. |
|
||
@cython.cdivision | ||
cdef char* c_strftime(date_info *dinfo, char *fmt): | ||
""" |
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.
as usual want to write doc-strings for things
thanks! |
Following on the heels of #19534, this removes a bunch of duplicate logic from period_helper and uses the implementations in np_datetime and ccalendar instead. A handful of functions are moved directly into period, but for the most part it's deletion.
git diff upstream/master -u -- "*.py" | flake8 --diff