Skip to content

Commit 3f82ed3

Browse files
authored
TST: unskip EA reduction tests (#59247)
unskip more EA reduction tests
1 parent 39bd3d3 commit 3f82ed3

File tree

5 files changed

+18
-36
lines changed

5 files changed

+18
-36
lines changed

pandas/core/arrays/masked.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,7 @@ def _wrap_na_result(self, *, name, axis, mask_size):
11981198
mask = np.ones(mask_size, dtype=bool)
11991199

12001200
float_dtyp = "float32" if self.dtype == "Float32" else "float64"
1201-
if name in ["mean", "median", "var", "std", "skew", "kurt"]:
1201+
if name in ["mean", "median", "var", "std", "skew", "kurt", "sem"]:
12021202
np_dtype = float_dtyp
12031203
elif name in ["min", "max"] or self.dtype.itemsize == 8:
12041204
np_dtype = self.dtype.numpy_dtype.name

pandas/tests/extension/base/reduce.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def check_reduce_frame(self, ser: pd.Series, op_name: str, skipna: bool):
5656
arr = ser.array
5757
df = pd.DataFrame({"a": arr})
5858

59-
kwargs = {"ddof": 1} if op_name in ["var", "std"] else {}
59+
kwargs = {"ddof": 1} if op_name in ["var", "std", "sem"] else {}
6060

6161
cmp_dtype = self._get_expected_reduction_dtype(arr, op_name, skipna)
6262

@@ -119,7 +119,7 @@ def test_reduce_frame(self, data, all_numeric_reductions, skipna):
119119
op_name = all_numeric_reductions
120120
ser = pd.Series(data)
121121

122-
if op_name in ["count", "kurt", "sem"]:
122+
if op_name == "count":
123123
pytest.skip(f"{op_name} not an array method")
124124

125125
if not self._supports_reduction(ser, op_name):

pandas/tests/extension/decimal/test_decimal.py

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ def _get_expected_exception(
7272
return None
7373

7474
def _supports_reduction(self, ser: pd.Series, op_name: str) -> bool:
75+
if op_name in ["kurt", "sem"]:
76+
return False
7577
return True
7678

7779
def check_reduce(self, ser: pd.Series, op_name: str, skipna: bool):

pandas/tests/extension/test_arrow.py

+11-29
Original file line numberDiff line numberDiff line change
@@ -467,17 +467,14 @@ def test_accumulate_series(self, data, all_numeric_accumulations, skipna, reques
467467
self.check_accumulate(ser, op_name, skipna)
468468

469469
def _supports_reduction(self, ser: pd.Series, op_name: str) -> bool:
470+
if op_name in ["kurt", "skew"]:
471+
return False
472+
470473
dtype = ser.dtype
471474
# error: Item "dtype[Any]" of "dtype[Any] | ExtensionDtype" has
472475
# no attribute "pyarrow_dtype"
473476
pa_dtype = dtype.pyarrow_dtype # type: ignore[union-attr]
474-
if pa.types.is_temporal(pa_dtype) and op_name in [
475-
"sum",
476-
"var",
477-
"skew",
478-
"kurt",
479-
"prod",
480-
]:
477+
if pa.types.is_temporal(pa_dtype) and op_name in ["sum", "var", "prod"]:
481478
if pa.types.is_duration(pa_dtype) and op_name in ["sum"]:
482479
# summing timedeltas is one case that *is* well-defined
483480
pass
@@ -493,8 +490,6 @@ def _supports_reduction(self, ser: pd.Series, op_name: str) -> bool:
493490
"std",
494491
"sem",
495492
"var",
496-
"skew",
497-
"kurt",
498493
]:
499494
return False
500495

@@ -541,23 +536,6 @@ def check_reduce(self, ser: pd.Series, op_name: str, skipna: bool):
541536
expected = getattr(alt, op_name)(skipna=skipna)
542537
tm.assert_almost_equal(result, expected)
543538

544-
@pytest.mark.parametrize("skipna", [True, False])
545-
def test_reduce_series_numeric(self, data, all_numeric_reductions, skipna, request):
546-
dtype = data.dtype
547-
pa_dtype = dtype.pyarrow_dtype
548-
549-
xfail_mark = pytest.mark.xfail(
550-
raises=TypeError,
551-
reason=(
552-
f"{all_numeric_reductions} is not implemented in "
553-
f"pyarrow={pa.__version__} for {pa_dtype}"
554-
),
555-
)
556-
if all_numeric_reductions in {"skew", "kurt"} and dtype._is_numeric:
557-
request.applymarker(xfail_mark)
558-
559-
super().test_reduce_series_numeric(data, all_numeric_reductions, skipna)
560-
561539
@pytest.mark.parametrize("skipna", [True, False])
562540
def test_reduce_series_boolean(
563541
self, data, all_boolean_reductions, skipna, na_value, request
@@ -596,11 +574,11 @@ def _get_expected_reduction_dtype(self, arr, op_name: str, skipna: bool):
596574
else:
597575
cmp_dtype = arr.dtype
598576
elif arr.dtype.name == "decimal128(7, 3)[pyarrow]":
599-
if op_name not in ["median", "var", "std"]:
577+
if op_name not in ["median", "var", "std", "sem"]:
600578
cmp_dtype = arr.dtype
601579
else:
602580
cmp_dtype = "float64[pyarrow]"
603-
elif op_name in ["median", "var", "std", "mean", "skew"]:
581+
elif op_name in ["median", "var", "std", "mean", "skew", "sem"]:
604582
cmp_dtype = "float64[pyarrow]"
605583
elif op_name in ["sum", "prod"] and pa.types.is_boolean(pa_type):
606584
cmp_dtype = "uint64[pyarrow]"
@@ -619,7 +597,11 @@ def test_reduce_frame(self, data, all_numeric_reductions, skipna, request):
619597
if data.dtype._is_numeric:
620598
mark = pytest.mark.xfail(reason="skew not implemented")
621599
request.applymarker(mark)
622-
elif op_name == "std" and pa.types.is_date64(data._pa_array.type) and skipna:
600+
elif (
601+
op_name in ["std", "sem"]
602+
and pa.types.is_date64(data._pa_array.type)
603+
and skipna
604+
):
623605
# overflow
624606
mark = pytest.mark.xfail(reason="Cannot cast")
625607
request.applymarker(mark)

pandas/tests/extension/test_masked.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def check_reduce(self, ser: pd.Series, op_name: str, skipna: bool):
301301
def _get_expected_reduction_dtype(self, arr, op_name: str, skipna: bool):
302302
if is_float_dtype(arr.dtype):
303303
cmp_dtype = arr.dtype.name
304-
elif op_name in ["mean", "median", "var", "std", "skew"]:
304+
elif op_name in ["mean", "median", "var", "std", "skew", "kurt", "sem"]:
305305
cmp_dtype = "Float64"
306306
elif op_name in ["max", "min"]:
307307
cmp_dtype = arr.dtype.name
@@ -323,9 +323,7 @@ def _get_expected_reduction_dtype(self, arr, op_name: str, skipna: bool):
323323
else "UInt64"
324324
)
325325
elif arr.dtype.kind == "b":
326-
if op_name in ["mean", "median", "var", "std", "skew"]:
327-
cmp_dtype = "Float64"
328-
elif op_name in ["min", "max"]:
326+
if op_name in ["min", "max"]:
329327
cmp_dtype = "boolean"
330328
elif op_name in ["sum", "prod"]:
331329
cmp_dtype = (

0 commit comments

Comments
 (0)