-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: Simplify rolling.py helper functions #30672
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
@@ -305,17 +290,6 @@ def _wrap_result(self, result, block=None, obj=None): | |||
|
|||
if isinstance(result, np.ndarray): | |||
|
|||
# coerce if necessary | |||
if block is not None: | |||
if is_timedelta64_dtype(block.values.dtype): |
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.
is this not reachable?
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.
Don't think so. Our test suite includes timedelta64 which doesn't his this branch.
Nice cleanup |
pandas/core/window/common.py
Outdated
@@ -250,31 +250,10 @@ def _get_center_of_mass(comass, span, halflife, alpha): | |||
return float(comass) | |||
|
|||
|
|||
def _offset(window, center): | |||
def _calculate_center_offset(window): |
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.
as a followup typing & doc-strings would be great. also ok to de-privatize these
pandas/core/window/rolling.py
Outdated
def func(arg, window, min_periods=None, closed=None): | ||
minp = check_minp(min_periods, len(window)) | ||
return cfunc(arg, window, minp, **kwargs) | ||
@staticmethod |
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.
instead of static can you make this a module level function, or is there a reason you want this as static?
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
@@ -336,3 +315,12 @@ def _prep_binary(arg1, arg2): | |||
Y = arg2 + 0 * arg1 | |||
|
|||
return X, Y | |||
|
|||
|
|||
def get_weighted_roll_func(cfunc: Callable) -> Callable: |
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.
Subtypes for Callable would be helpful here if you know from looking at this what they are
thanks @mroeschke doc-strings and types always welcome |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
Cleans helper functions in
rolling.py
and remove dead code paths.