Skip to content

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

Merged
merged 7 commits into from
Feb 28, 2020
Merged

CLN: some code cleanups #32177

merged 7 commits into from
Feb 28, 2020

Conversation

ShaharNaveh
Copy link
Member

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

@ShaharNaveh ShaharNaveh reopened this Feb 22, 2020
@@ -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):
Copy link
Member

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

Copy link
Contributor

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

If datetime, convert to datetime.datetime
If date, convert to datetime.date
If time, convert to datetime.time
If Timestamp, convert to pandas.Timestamp
Copy link
Member

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?

Copy link
Contributor

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


Returns
-------
result : array of dtype specified by box
array of dtype specified by box
Copy link
Member

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,
Copy link
Member

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[:]?

Copy link
Member

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

Copy link
Member

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

Copy link
Contributor

@jreback jreback left a 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):
Copy link
Contributor

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

If datetime, convert to datetime.datetime
If date, convert to datetime.date
If time, convert to datetime.time
If Timestamp, convert to pandas.Timestamp
Copy link
Contributor

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

@jreback jreback added the Clean label Feb 23, 2020
Copy link
Member

@WillAyd WillAyd left a 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

@WillAyd WillAyd added this to the 1.1 milestone Feb 24, 2020
@simonjayhawkins
Copy link
Member

@MomIsBestFriend IIUC cython support for black is under development, psf/black#359.

@ShaharNaveh
Copy link
Member Author

@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 😆

@WillAyd
Copy link
Member

WillAyd commented Feb 26, 2020

Can you merge master? Otherwise I think this is good to go

Copy link
Member

@datapythonista datapythonista left a 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!

@simonjayhawkins
Copy link
Member

@MomIsBestFriend looking at the diff of the merge master, it looks like you've lost some of your clean-ups.

@ShaharNaveh
Copy link
Member Author

@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.

Copy link
Member

@simonjayhawkins simonjayhawkins left a 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

@datapythonista
Copy link
Member

All green. @jreback you requested changes, if you want to have another look, this should be ready.

@jreback
Copy link
Contributor

jreback commented Feb 28, 2020

ok as long as purely cosmetic

@WillAyd WillAyd merged commit ece0517 into pandas-dev:master Feb 28, 2020
@WillAyd
Copy link
Member

WillAyd commented Feb 28, 2020

Thanks @MomIsBestFriend

@ShaharNaveh ShaharNaveh deleted the CLN-libs-2 branch February 29, 2020 10:27
roberthdevries pushed a commit to roberthdevries/pandas that referenced this pull request Mar 2, 2020
@ShaharNaveh ShaharNaveh mentioned this pull request Mar 13, 2020
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants