Skip to content

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

Merged
merged 9 commits into from
Jan 5, 2020

Conversation

mroeschke
Copy link
Member

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

Cleans helper functions in rolling.py and remove dead code paths.

@mroeschke mroeschke added Clean Window rolling, ewma, expanding labels Jan 4, 2020
@@ -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):
Copy link
Member

Choose a reason for hiding this comment

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

is this not reachable?

Copy link
Member Author

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.

@jbrockmendel
Copy link
Member

Nice cleanup

@jreback jreback added this to the 1.0 milestone Jan 4, 2020
@@ -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):
Copy link
Contributor

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

def func(arg, window, min_periods=None, closed=None):
minp = check_minp(min_periods, len(window))
return cfunc(arg, window, minp, **kwargs)
@staticmethod
Copy link
Contributor

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?

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

@@ -336,3 +315,12 @@ def _prep_binary(arg1, arg2):
Y = arg2 + 0 * arg1

return X, Y


def get_weighted_roll_func(cfunc: Callable) -> Callable:
Copy link
Member

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

@jreback
Copy link
Contributor

jreback commented Jan 5, 2020

thanks @mroeschke

doc-strings and types always welcome

@jreback jreback merged commit 863a6a4 into pandas-dev:master Jan 5, 2020
@mroeschke mroeschke deleted the clean_rolling branch April 21, 2020 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Window rolling, ewma, expanding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants