Skip to content

TYPING: pandas/core/window.py #27391

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
Jul 18, 2019
Merged

Conversation

mroeschke
Copy link
Member

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

Includes simplifying some code paths

@mroeschke mroeschke added Typing type annotations, mypy/pyright type checking Window rolling, ewma, expanding labels Jul 15, 2019
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.

Looks pretty good - just a few things. Thanks for taking a look at this!

min_periods: Optional[int] = None,
center: Optional[bool] = False,
win_type: Optional[str] = None,
axis: Union[str, int] = 0,
Copy link
Member

Choose a reason for hiding this comment

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

Can you put this in pandas._typing as Axis and reference here?

cc @topper-123 as this might conflict with your other PR

def _wrap_result(self, result, block=None, obj=None):
def _wrap_result(
self, result, block=None, obj=None
) -> Union[ABCSeries, ABCDataFrame]:
Copy link
Member

Choose a reason for hiding this comment

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

Should use FrameOrSeries from pandas._typing

@@ -63,19 +63,19 @@ class _Window(PandasObject, SelectionMixin):
"axis",
"on",
"closed",
]
] # type: List[str]
Copy link
Member

Choose a reason for hiding this comment

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

Was this actually throwing an error? Not opposed to it just surprised Mypy wouldn't infer this already

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; just thought to go ahead and type.

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 - thanks for typing and simplifying signatures

@mroeschke mroeschke merged commit a4c19e7 into pandas-dev:master Jul 18, 2019
@mroeschke
Copy link
Member Author

Thanks for reviewing @WillAyd!

@mroeschke mroeschke deleted the windows_typing branch July 18, 2019 00:06
another-green pushed a commit to another-green/pandas that referenced this pull request Jul 20, 2019
* TYPING: pandas/core/window.py

* Address comments

* Remove unused import

* Sort imports
values = values.copy()
values[np.isinf(values)] = np.NaN
# Always convert inf to nan
values[np.isinf(values)] = np.NaN
Copy link
Contributor

Choose a reason for hiding this comment

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

You missed a copy call here. Results in kernc/backtesting.py#14 on write-protected arrays.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing type annotations, mypy/pyright type checking Window rolling, ewma, expanding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants