Skip to content

CLN: separate raising from non-raising parts of method #27151

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 13 commits into from
Jul 2, 2019

Conversation

jbrockmendel
Copy link
Member

There is lots of code in core.internals inside try/except blocks, in particular calls to _try_coerce_args. It is tough to reason about these because it is often unclear what the raising cases are. This simplifies that problem by separating values, args = self._try_coerce_args(values, args) into values = self._coerce_values(values) and args = self._try_coerce_args(args) (Note the former doesnt have a "try" in the name because it never raises).

Also: removed a never-used ndim kwarg from Block.make_block and removed a now-redundant DatetimeTZBlock.copy method.

@jbrockmendel
Copy link
Member Author

@jorisvandenbossche CI fails look unrelated, ami missing something?

@jorisvandenbossche
Copy link
Member

@mroeschke mentioned those should be fixed by a commit in #27144 (comment)

@gfyoung gfyoung added Clean Internals Related to non-user accessible pandas implementation labels Jul 1, 2019
@jbrockmendel
Copy link
Member Author

yep, that fixed it, thanks.

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.

lgtm. if you can fix the doc-strings (on the super class); ok to remove from the other _coerce_values.

@@ -659,7 +659,13 @@ def _try_cast_result(self, result, dtype=None):
# may need to change the dtype here
return maybe_downcast_to_dtype(result, dtype)

def _try_coerce_args(self, values, other):
def _coerce_values(self, values):
Copy link
Contributor

Choose a reason for hiding this comment

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

if possible can you add types (ok for future PR) and full doc-strings

@@ -2116,25 +2126,28 @@ def _can_hold_element(self, element):
return (is_integer(element) or isinstance(element, datetime) or
isna(element))

def _try_coerce_args(self, values, other):
def _coerce_values(self, values):
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

you can omit the doc-strings (as will inherit from super class)

@@ -2484,21 +2494,25 @@ def fillna(self, value, **kwargs):
value = Timedelta(value, unit='s')
return super().fillna(value, **kwargs)

def _try_coerce_args(self, values, other):
def _coerce_values(self, values):
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

can omit doc-string

@jreback jreback added this to the 0.25.0 milestone Jul 1, 2019
@jreback
Copy link
Contributor

jreback commented Jul 2, 2019

lgtm. ping on green.

would really love a typing PR on blocks :->

@jbrockmendel
Copy link
Member Author

psuedo-ping. CI has been in this state for 13 hours

@TomAugspurger TomAugspurger merged commit 8507170 into pandas-dev:master Jul 2, 2019
@TomAugspurger
Copy link
Contributor

CI finished, seems like Github missed the notification.

FYI @jbrockmendel let me know if you want to be added to the azure team so you can restart builds. Just need an azure account name.

@jbrockmendel jbrockmendel deleted the try_coerce branch July 2, 2019 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Internals Related to non-user accessible pandas implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants