-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Conversation
@jorisvandenbossche CI fails look unrelated, ami missing something? |
@mroeschke mentioned those should be fixed by a commit in #27144 (comment) |
yep, that fixed it, thanks. |
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. 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): |
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.
if possible can you add types (ok for future PR) and full doc-strings
pandas/core/internals/blocks.py
Outdated
@@ -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): | |||
""" |
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.
you can omit the doc-strings (as will inherit from super class)
pandas/core/internals/blocks.py
Outdated
@@ -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): | |||
""" |
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 omit doc-string
lgtm. ping on green. would really love a typing PR on blocks :-> |
psuedo-ping. CI has been in this state for 13 hours |
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. |
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)
intovalues = self._coerce_values(values)
andargs = 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 fromBlock.make_block
and removed a now-redundantDatetimeTZBlock.copy
method.