-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: remove unneeded try/except in nanops #52684
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1067,22 +1067,14 @@ def reduction( | |
axis: AxisInt | None = None, | ||
skipna: bool = True, | ||
mask: npt.NDArray[np.bool_] | None = None, | ||
) -> Dtype: | ||
dtype = values.dtype | ||
): | ||
if values.size == 0: | ||
return _na_for_min_count(values, axis) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume we have tests that get here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The You can see this function is wrapped in I just think this is more readable than the old code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotcha. Thanks for the explanation |
||
|
||
values, mask = _get_values( | ||
values, skipna, fill_value_typ=fill_value_typ, mask=mask | ||
) | ||
|
||
if (axis is not None and values.shape[axis] == 0) or values.size == 0: | ||
dtype_max = _get_dtype_max(dtype) | ||
try: | ||
result = getattr(values, meth)(axis, dtype=dtype_max) | ||
result.fill(np.nan) | ||
except (AttributeError, TypeError, ValueError): | ||
result = np.nan | ||
else: | ||
result = getattr(values, meth)(axis) | ||
|
||
result = getattr(values, meth)(axis) | ||
result = _maybe_null_out(result, axis, mask, values.shape) | ||
return result | ||
|
||
|
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 we keep this type annotation?
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 annotation was wrong and this doesn't return a
Dtype
but the the result of a min/max of a DataFrame/Series, i.e. typically a scalar or a ndarray (but the min/max of a Series can in principle be anything....)IDK if we return type
Scalar
as annotation for Series?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.
Yeah not either, but since this is an inner function the typing here probably doesn't matter as much