-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
TYPING: Added types for some tests #29205
Changes from 1 commit
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 |
---|---|---|
|
@@ -118,3 +118,4 @@ doc/build/html/index.html | |
doc/tmp.sv | ||
env/ | ||
doc/source/savefig/ | ||
.dmypy.json |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
|
||
import pandas as pd | ||
from pandas import DataFrame | ||
from pandas._typing import IndexOrSeries | ||
from pandas.core import ops | ||
import pandas.util.testing as tm | ||
|
||
|
@@ -790,6 +791,17 @@ def tick_classes(request): | |
return request.param | ||
|
||
|
||
index_or_series_params = [pd.Index, pd.Series] # type: IndexOrSeries | ||
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.
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. Should this be 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. good catch. agree that strange it doesn't fail |
||
|
||
|
||
@pytest.fixture(params=index_or_series_params, ids=["series", "index"]) | ||
WillAyd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def index_or_series(request) -> IndexOrSeries: | ||
""" | ||
Parametrized fixture providing the Index or Series class. | ||
""" | ||
return request.param | ||
|
||
|
||
# ---------------------------------------------------------------- | ||
# Global setup for tests using Hypothesis | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5,6 +5,7 @@ | |||||
from decimal import Decimal | ||||||
from itertools import combinations | ||||||
import operator | ||||||
from typing import List, Type, Union | ||||||
|
||||||
import numpy as np | ||||||
import pytest | ||||||
|
@@ -74,33 +75,22 @@ def test_compare_invalid(self): | |||||
|
||||||
# ------------------------------------------------------------------ | ||||||
# Numeric dtypes Arithmetic with Datetime/Timedelta Scalar | ||||||
index_or_series_params = [ | ||||||
pd.Series, | ||||||
pd.Index, | ||||||
] # type: List[Union[Type[pd.Index], Type[pd.RangeIndex], Type[pd.Series]]] | ||||||
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.
Suggested change
Can shorten this quite a bit if you put the |
||||||
left = [pd.RangeIndex(10, 40, 10)] # type: List[Union[Index, Series]] | ||||||
for cls in index_or_series_params: | ||||||
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. isn’t this any_numeric_dtype ? 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. This seems to include float16. Aside from that, they look the same at a glance. 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. we barely support float16 would just remove and use the fixture |
||||||
for dtype in ["i1", "i2", "i4", "i8", "u1", "u2", "u4", "u8", "f2", "f4", "f8"]: | ||||||
left.append(cls([10, 20, 30], dtype=dtype)) | ||||||
|
||||||
|
||||||
class TestNumericArraylikeArithmeticWithDatetimeLike: | ||||||
|
||||||
# TODO: also check name retentention | ||||||
@pytest.mark.parametrize("box_cls", [np.array, pd.Index, pd.Series]) | ||||||
@pytest.mark.parametrize( | ||||||
"left", | ||||||
[pd.RangeIndex(10, 40, 10)] | ||||||
+ [ | ||||||
WillAyd marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
cls([10, 20, 30], dtype=dtype) | ||||||
for dtype in [ | ||||||
"i1", | ||||||
"i2", | ||||||
"i4", | ||||||
"i8", | ||||||
"u1", | ||||||
"u2", | ||||||
"u4", | ||||||
"u8", | ||||||
"f2", | ||||||
"f4", | ||||||
"f8", | ||||||
] | ||||||
for cls in [pd.Series, pd.Index] | ||||||
], | ||||||
ids=lambda x: type(x).__name__ + str(x.dtype), | ||||||
"left", left, ids=lambda x: type(x).__name__ + str(x.dtype) | ||||||
) | ||||||
def test_mul_td64arr(self, left, box_cls): | ||||||
# GH#22390 | ||||||
|
@@ -120,26 +110,7 @@ def test_mul_td64arr(self, left, box_cls): | |||||
# TODO: also check name retentention | ||||||
@pytest.mark.parametrize("box_cls", [np.array, pd.Index, pd.Series]) | ||||||
@pytest.mark.parametrize( | ||||||
"left", | ||||||
[pd.RangeIndex(10, 40, 10)] | ||||||
+ [ | ||||||
cls([10, 20, 30], dtype=dtype) | ||||||
for dtype in [ | ||||||
"i1", | ||||||
"i2", | ||||||
"i4", | ||||||
"i8", | ||||||
"u1", | ||||||
"u2", | ||||||
"u4", | ||||||
"u8", | ||||||
"f2", | ||||||
"f4", | ||||||
"f8", | ||||||
] | ||||||
for cls in [pd.Series, pd.Index] | ||||||
], | ||||||
ids=lambda x: type(x).__name__ + str(x.dtype), | ||||||
"left", left, ids=lambda x: type(x).__name__ + str(x.dtype) | ||||||
) | ||||||
def test_div_td64arr(self, left, box_cls): | ||||||
# GH#22390 | ||||||
|
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 meant to include array likes, eg EA? as well
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.
Nope, just Index and Series.