Skip to content

Commit 4096733

Browse files
authored
TYP: more precise types + add type collections (#51234)
TYP: more precise types + add som etype collections
1 parent fae47ff commit 4096733

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

pandas/_testing/__init__.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,10 @@
133133
ALL_INT_EA_DTYPES = UNSIGNED_INT_EA_DTYPES + SIGNED_INT_EA_DTYPES
134134
ALL_INT_DTYPES: list[Dtype] = [*ALL_INT_NUMPY_DTYPES, *ALL_INT_EA_DTYPES]
135135

136-
FLOAT_NUMPY_DTYPES: list[Dtype] = [float, "float32", "float64"]
136+
FLOAT_NUMPY_DTYPES: list[NpDtype] = [float, "float32", "float64"]
137137
FLOAT_EA_DTYPES: list[Dtype] = ["Float32", "Float64"]
138+
ALL_FLOAT_DTYPES: list[Dtype] = [*FLOAT_NUMPY_DTYPES, *FLOAT_EA_DTYPES]
139+
138140
COMPLEX_DTYPES: list[Dtype] = [complex, "complex64", "complex128"]
139141
STRING_DTYPES: list[Dtype] = [str, "str", "U"]
140142

@@ -146,6 +148,10 @@
146148
OBJECT_DTYPES: list[Dtype] = [object, "object"]
147149

148150
ALL_REAL_NUMPY_DTYPES = FLOAT_NUMPY_DTYPES + ALL_INT_NUMPY_DTYPES
151+
ALL_REAL_EXTENSION_DTYPES = FLOAT_EA_DTYPES + ALL_INT_EA_DTYPES
152+
ALL_REAL_DTYPES: list[Dtype] = [*ALL_REAL_NUMPY_DTYPES, *ALL_REAL_EXTENSION_DTYPES]
153+
ALL_NUMERIC_DTYPES: list[Dtype] = [*ALL_REAL_DTYPES, *COMPLEX_DTYPES]
154+
149155
ALL_NUMPY_DTYPES = (
150156
ALL_REAL_NUMPY_DTYPES
151157
+ COMPLEX_DTYPES

pandas/conftest.py

+3-10
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,7 @@ def float_ea_dtype(request):
14091409
return request.param
14101410

14111411

1412-
@pytest.fixture(params=tm.FLOAT_NUMPY_DTYPES + tm.FLOAT_EA_DTYPES)
1412+
@pytest.fixture(params=tm.ALL_FLOAT_DTYPES)
14131413
def any_float_dtype(request):
14141414
"""
14151415
Parameterized fixture for float dtypes.
@@ -1614,9 +1614,7 @@ def any_real_numpy_dtype(request):
16141614
return request.param
16151615

16161616

1617-
@pytest.fixture(
1618-
params=tm.ALL_REAL_NUMPY_DTYPES + tm.ALL_INT_EA_DTYPES + tm.FLOAT_EA_DTYPES
1619-
)
1617+
@pytest.fixture(params=tm.ALL_REAL_DTYPES)
16201618
def any_real_numeric_dtype(request):
16211619
"""
16221620
Parameterized fixture for any (purely) real numeric dtype.
@@ -1676,12 +1674,7 @@ def any_numpy_dtype(request):
16761674
return request.param
16771675

16781676

1679-
@pytest.fixture(
1680-
params=tm.ALL_REAL_NUMPY_DTYPES
1681-
+ tm.COMPLEX_DTYPES
1682-
+ tm.ALL_INT_EA_DTYPES
1683-
+ tm.FLOAT_EA_DTYPES
1684-
)
1677+
@pytest.fixture(params=tm.ALL_NUMERIC_DTYPES)
16851678
def any_numeric_dtype(request):
16861679
"""
16871680
Parameterized fixture for all numeric dtypes.

pandas/tests/frame/test_constructors.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -2262,10 +2262,7 @@ def test_constructor_categorical_series(self):
22622262

22632263
@pytest.mark.parametrize(
22642264
"dtype",
2265-
tm.ALL_INT_NUMPY_DTYPES
2266-
+ tm.ALL_INT_EA_DTYPES
2267-
+ tm.FLOAT_NUMPY_DTYPES
2268-
+ tm.COMPLEX_DTYPES
2265+
tm.ALL_NUMERIC_DTYPES
22692266
+ tm.DATETIME64_DTYPES
22702267
+ tm.TIMEDELTA64_DTYPES
22712268
+ tm.BOOL_DTYPES,

0 commit comments

Comments
 (0)