Skip to content

Commit fe1ea14

Browse files
CLN: consistent EA._reduce signatures (#35308)
1 parent cd5e17c commit fe1ea14

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

pandas/core/arrays/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ def _concat_same_type(
11201120
# of objects
11211121
_can_hold_na = True
11221122

1123-
def _reduce(self, name, skipna=True, **kwargs):
1123+
def _reduce(self, name: str, skipna: bool = True, **kwargs):
11241124
"""
11251125
Return a scalar result of performing the reduction operation.
11261126

pandas/core/arrays/categorical.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2076,11 +2076,11 @@ def _reverse_indexer(self) -> Dict[Hashable, np.ndarray]:
20762076
return result
20772077

20782078
# reduction ops #
2079-
def _reduce(self, name, axis=0, **kwargs):
2079+
def _reduce(self, name: str, skipna: bool = True, **kwargs):
20802080
func = getattr(self, name, None)
20812081
if func is None:
20822082
raise TypeError(f"Categorical cannot perform the operation {name}")
2083-
return func(**kwargs)
2083+
return func(skipna=skipna, **kwargs)
20842084

20852085
@deprecate_kwarg(old_arg_name="numeric_only", new_arg_name="skipna")
20862086
def min(self, skipna=True, **kwargs):

pandas/core/arrays/datetimelike.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1552,7 +1552,7 @@ def __isub__(self, other):
15521552
# --------------------------------------------------------------
15531553
# Reductions
15541554

1555-
def _reduce(self, name, axis=0, skipna=True, **kwargs):
1555+
def _reduce(self, name: str, skipna: bool = True, **kwargs):
15561556
op = getattr(self, name, None)
15571557
if op:
15581558
return op(skipna=skipna, **kwargs)

pandas/core/arrays/sparse/array.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ def nonzero(self):
11641164
# Reductions
11651165
# ------------------------------------------------------------------------
11661166

1167-
def _reduce(self, name, skipna=True, **kwargs):
1167+
def _reduce(self, name: str, skipna: bool = True, **kwargs):
11681168
method = getattr(self, name, None)
11691169

11701170
if method is None:

pandas/core/arrays/string_.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def astype(self, dtype, copy=True):
291291

292292
return super().astype(dtype, copy)
293293

294-
def _reduce(self, name, skipna=True, **kwargs):
294+
def _reduce(self, name: str, skipna: bool = True, **kwargs):
295295
if name in ["min", "max"]:
296296
return getattr(self, name)(skipna=skipna)
297297

pandas/tests/extension/arrow/arrays.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,14 @@ def _concat_same_type(cls, to_concat):
162162
def __invert__(self):
163163
return type(self).from_scalars(~self._data.to_pandas())
164164

165-
def _reduce(self, method, skipna=True, **kwargs):
165+
def _reduce(self, name: str, skipna: bool = True, **kwargs):
166166
if skipna:
167167
arr = self[~self.isna()]
168168
else:
169169
arr = self
170170

171171
try:
172-
op = getattr(arr, method)
172+
op = getattr(arr, name)
173173
except AttributeError as err:
174174
raise TypeError from err
175175
return op(**kwargs)

pandas/tests/extension/decimal/array.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def _formatter(self, boxed=False):
174174
def _concat_same_type(cls, to_concat):
175175
return cls(np.concatenate([x._data for x in to_concat]))
176176

177-
def _reduce(self, name, skipna=True, **kwargs):
177+
def _reduce(self, name: str, skipna: bool = True, **kwargs):
178178

179179
if skipna:
180180
# If we don't have any NAs, we can ignore skipna

0 commit comments

Comments
 (0)