-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: some code cleanups #32177
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
CLN: some code cleanups #32177
Conversation
@@ -481,8 +481,7 @@ cdef class Interval(IntervalMixin): | |||
|
|||
@cython.wraparound(False) | |||
@cython.boundscheck(False) | |||
def intervals_to_interval_bounds(ndarray intervals, | |||
bint validate_closed=True): | |||
def intervals_to_interval_bounds(ndarray intervals, bint validate_closed=True): |
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.
its worth double-checking me on this, but i think for non-cdef/cpdef functions, using cython syntax for the annotations doesnt help perf. in these cases, let's just use python versions
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.
right, but that is orthogonal to this PR
pandas/_libs/tslib.pyx
Outdated
If datetime, convert to datetime.datetime | ||
If date, convert to datetime.date | ||
If time, convert to datetime.time | ||
If Timestamp, convert to pandas.Timestamp |
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.
do we usually use dashes or asterisks or something for this kind of bullet point thing?
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.
can use astericks i think
pandas/_libs/tslib.pyx
Outdated
|
||
Returns | ||
------- | ||
result : array of dtype specified by box | ||
array of dtype specified by box |
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.
dtype is always object, the type contained is specified by box. let's also specify ndarray instead of just array
def format_array_from_datetime(ndarray[int64_t] values, object tz=None, | ||
object format=None, object na_rep=None): | ||
def format_array_from_datetime( | ||
ndarray[int64_t] values, |
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.
possibly can make const int64_t[:]
?
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.
I think should hold off on these types of changes until we get warnings to error, unless there is a known upside
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.
its the usage encouraged by the cython folks, supposed to be slightly faster. very marginal
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.
@MomIsBestFriend i think just some minor comments, anything that is mentioned as a perf change should be done independetnl. pls call out anything non-trivial (e.g. formatting) that is changed. or just don't do anything that is non formatting / style in this PR
@@ -481,8 +481,7 @@ cdef class Interval(IntervalMixin): | |||
|
|||
@cython.wraparound(False) | |||
@cython.boundscheck(False) | |||
def intervals_to_interval_bounds(ndarray intervals, | |||
bint validate_closed=True): | |||
def intervals_to_interval_bounds(ndarray intervals, bint validate_closed=True): |
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.
right, but that is orthogonal to this PR
pandas/_libs/tslib.pyx
Outdated
If datetime, convert to datetime.datetime | ||
If date, convert to datetime.date | ||
If time, convert to datetime.time | ||
If Timestamp, convert to pandas.Timestamp |
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.
can use astericks i think
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.
lgtm as a style fixup; @jbrockmendel has valid comments but I think should all be done separate
@MomIsBestFriend IIUC cython support for black is under development, psf/black#359. |
Thank you @simonjayhawkins, me and my OCD are thrilled, I subscribed to that thread 😆 |
Can you merge master? Otherwise I think this is good to go |
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.
lgtm, nice clean up @MomIsBestFriend
If you address the review comments, please do it in a separate PR. This touches a lot of code, better not to have any functional change here, only style changes.
Thanks!
@MomIsBestFriend looking at the diff of the merge master, it looks like you've lost some of your clean-ups. |
@simonjayhawkins Correct, in 1cc4e89 I have reverted everything lost in the merge conflicts. |
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.
Thanks @MomIsBestFriend lgtm pending green
All green. @jreback you requested changes, if you want to have another look, this should be ready. |
ok as long as purely cosmetic |
Thanks @MomIsBestFriend |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff