Skip to content

CLN: Remove unnecessary rolling subclass #36721

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 4 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pandas/core/window/ewm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import pandas.core.common as common
from pandas.core.window.common import _doc_template, _shared_docs, zsqrt
from pandas.core.window.rolling import RollingMixin, flex_binary_moment
from pandas.core.window.rolling import BaseWindow, flex_binary_moment

_bias_template = """
Parameters
Expand Down Expand Up @@ -60,7 +60,7 @@ def get_center_of_mass(
return float(comass)


class ExponentialMovingWindow(RollingMixin):
class ExponentialMovingWindow(BaseWindow):
r"""
Provide exponential weighted (EW) functions.

Expand Down
26 changes: 13 additions & 13 deletions pandas/core/window/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ def func(arg, window, min_periods=None):
return func


class _Window(ShallowMixin, SelectionMixin):
class BaseWindow(ShallowMixin, SelectionMixin):
"""Provides utilities for performing windowing operations."""

_attributes: List[str] = [
"window",
"min_periods",
Expand Down Expand Up @@ -184,10 +186,6 @@ def __init__(
self.axis = obj._get_axis_number(axis) if axis is not None else None
self.validate()

@property
def _constructor(self):
return Window

@property
def is_datetimelike(self) -> Optional[bool]:
return None
Expand Down Expand Up @@ -862,7 +860,7 @@ def aggregate(self, func, *args, **kwargs):
)


class Window(_Window):
class Window(BaseWindow):
"""
Provide rolling window calculations.

Expand Down Expand Up @@ -1040,6 +1038,10 @@ class Window(_Window):
2013-01-01 09:00:06 4.0
"""

@property
def _constructor(self):
return Window

def validate(self):
super().validate()

Expand Down Expand Up @@ -1220,13 +1222,7 @@ def std(self, ddof=1, *args, **kwargs):
return zsqrt(self.var(ddof=ddof, name="std", **kwargs))


class RollingMixin(_Window):
@property
def _constructor(self):
return Rolling


class RollingAndExpandingMixin(RollingMixin):
class RollingAndExpandingMixin(BaseWindow):

_shared_docs["count"] = dedent(
r"""
Expand Down Expand Up @@ -1939,6 +1935,10 @@ def _on(self) -> Index:
"must be a column (of DataFrame), an Index or None"
)

@property
def _constructor(self):
return Rolling

def validate(self):
super().validate()

Expand Down