Skip to content

Commit ef50cd6

Browse files
authored
TST: dont skip dt64tz rolling tests (#44730)
1 parent f31c2b3 commit ef50cd6

File tree

2 files changed

+18
-21
lines changed

2 files changed

+18
-21
lines changed

pandas/tests/window/conftest.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,7 @@ def halflife_with_times(request):
200200
"float64",
201201
"m8[ns]",
202202
"M8[ns]",
203-
pytest.param(
204-
"datetime64[ns, UTC]",
205-
marks=pytest.mark.skip(
206-
"direct creation of extension dtype datetime64[ns, UTC] "
207-
"is not supported ATM"
208-
),
209-
),
203+
"datetime64[ns, UTC]",
210204
]
211205
)
212206
def dtypes(request):

pandas/tests/window/test_dtypes.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import numpy as np
22
import pytest
33

4+
from pandas.core.dtypes.common import pandas_dtype
5+
46
from pandas import (
57
NA,
68
DataFrame,
@@ -19,9 +21,7 @@
1921
def get_dtype(dtype, coerce_int=None):
2022
if coerce_int is False and "int" in dtype:
2123
return None
22-
if dtype != "category":
23-
return np.dtype(dtype)
24-
return dtype
24+
return pandas_dtype(dtype)
2525

2626

2727
@pytest.mark.parametrize(
@@ -66,21 +66,23 @@ def get_dtype(dtype, coerce_int=None):
6666
],
6767
)
6868
def test_series_dtypes(method, data, expected_data, coerce_int, dtypes, min_periods):
69-
s = Series(data, dtype=get_dtype(dtypes, coerce_int=coerce_int))
70-
if dtypes in ("m8[ns]", "M8[ns]") and method != "count":
69+
ser = Series(data, dtype=get_dtype(dtypes, coerce_int=coerce_int))
70+
rolled = ser.rolling(2, min_periods=min_periods)
71+
72+
if dtypes in ("m8[ns]", "M8[ns]", "datetime64[ns, UTC]") and method != "count":
7173
msg = "No numeric types to aggregate"
7274
with pytest.raises(DataError, match=msg):
73-
getattr(s.rolling(2, min_periods=min_periods), method)()
75+
getattr(rolled, method)()
7476
else:
75-
result = getattr(s.rolling(2, min_periods=min_periods), method)()
77+
result = getattr(rolled, method)()
7678
expected = Series(expected_data, dtype="float64")
7779
tm.assert_almost_equal(result, expected)
7880

7981

8082
def test_series_nullable_int(any_signed_int_ea_dtype):
8183
# GH 43016
82-
s = Series([0, 1, NA], dtype=any_signed_int_ea_dtype)
83-
result = s.rolling(2).mean()
84+
ser = Series([0, 1, NA], dtype=any_signed_int_ea_dtype)
85+
result = ser.rolling(2).mean()
8486
expected = Series([np.nan, 0.5, np.nan])
8587
tm.assert_series_equal(result, expected)
8688

@@ -130,14 +132,15 @@ def test_series_nullable_int(any_signed_int_ea_dtype):
130132
],
131133
)
132134
def test_dataframe_dtypes(method, expected_data, dtypes, min_periods):
133-
if dtypes == "category":
134-
pytest.skip("Category dataframe testing not implemented.")
135+
135136
df = DataFrame(np.arange(10).reshape((5, 2)), dtype=get_dtype(dtypes))
136-
if dtypes in ("m8[ns]", "M8[ns]") and method != "count":
137+
rolled = df.rolling(2, min_periods=min_periods)
138+
139+
if dtypes in ("m8[ns]", "M8[ns]", "datetime64[ns, UTC]") and method != "count":
137140
msg = "No numeric types to aggregate"
138141
with pytest.raises(DataError, match=msg):
139-
getattr(df.rolling(2, min_periods=min_periods), method)()
142+
getattr(rolled, method)()
140143
else:
141-
result = getattr(df.rolling(2, min_periods=min_periods), method)()
144+
result = getattr(rolled, method)()
142145
expected = DataFrame(expected_data, dtype="float64")
143146
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)