Skip to content

Commit 9c37226

Browse files
jbrockmendeljorisvandenbossche
authored andcommitted
CLN: rename reduce-->do_reduce (#27706)
1 parent d330416 commit 9c37226

File tree

14 files changed

+32
-45
lines changed

14 files changed

+32
-45
lines changed

pandas/_libs/reduction.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ cdef class BlockSlider:
628628
arr.shape[1] = 0
629629

630630

631-
def reduce(arr, f, axis=0, dummy=None, labels=None):
631+
def compute_reduction(arr, f, axis=0, dummy=None, labels=None):
632632
"""
633633
634634
Parameters

pandas/_libs/tslibs/timedeltas.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,8 @@ class Timedelta(_Timedelta):
12801280
else:
12811281
raise ValueError(
12821282
"Value must be Timedelta, string, integer, "
1283-
"float, timedelta or convertible")
1283+
"float, timedelta or convertible, not {typ}"
1284+
.format(typ=type(value).__name__))
12841285

12851286
if is_timedelta64_object(value):
12861287
value = value.view('i8')

pandas/core/apply.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def apply_raw(self):
221221
""" apply to the values as a numpy array """
222222

223223
try:
224-
result = reduction.reduce(self.values, self.f, axis=self.axis)
224+
result = reduction.compute_reduction(self.values, self.f, axis=self.axis)
225225
except Exception:
226226
result = np.apply_along_axis(self.f, self.axis, self.values)
227227

@@ -281,7 +281,7 @@ def apply_standard(self):
281281
dummy = Series(empty_arr, index=index, dtype=values.dtype)
282282

283283
try:
284-
result = reduction.reduce(
284+
result = reduction.compute_reduction(
285285
values, self.f, axis=self.axis, dummy=dummy, labels=labels
286286
)
287287
return self.obj._constructor_sliced(result, index=labels)

pandas/core/arrays/categorical.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2703,7 +2703,7 @@ def _convert_to_list_like(list_like):
27032703
elif is_scalar(list_like):
27042704
return [list_like]
27052705
else:
2706-
# is this reached?
2706+
# TODO: is this reached?
27072707
return [list_like]
27082708

27092709

pandas/core/arrays/datetimelike.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,10 @@
5757
class AttributesMixin:
5858
_data = None # type: np.ndarray
5959

60-
@property
61-
def _attributes(self):
62-
# Inheriting subclass should implement _attributes as a list of strings
63-
raise AbstractMethodError(self)
64-
6560
@classmethod
6661
def _simple_new(cls, values, **kwargs):
6762
raise AbstractMethodError(cls)
6863

69-
def _get_attributes_dict(self):
70-
"""
71-
return an attributes dict for my class
72-
"""
73-
return {k: getattr(self, k, None) for k in self._attributes}
74-
7564
@property
7665
def _scalar_type(self) -> Type[DatetimeLikeScalar]:
7766
"""The scalar associated with this datelike

pandas/core/arrays/datetimes.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ class DatetimeArray(dtl.DatetimeLikeArrayMixin, dtl.TimelikeOps, dtl.DatelikeOps
328328
# -----------------------------------------------------------------
329329
# Constructors
330330

331-
_attributes = ["freq", "tz"]
332331
_dtype = None # type: Union[np.dtype, DatetimeTZDtype]
333332
_freq = None
334333

pandas/core/arrays/period.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ class PeriodArray(dtl.DatetimeLikeArrayMixin, dtl.DatelikeOps):
161161

162162
# array priority higher than numpy scalars
163163
__array_priority__ = 1000
164-
_attributes = ["freq"]
165164
_typ = "periodarray" # ABCPeriodArray
166165
_scalar_type = Period
167166

pandas/core/arrays/timedeltas.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ def dtype(self):
199199

200200
# ----------------------------------------------------------------
201201
# Constructors
202-
_attributes = ["freq"]
203202

204203
def __init__(self, values, dtype=_TD_DTYPE, freq=None, copy=False):
205204
if isinstance(values, (ABCSeries, ABCIndexClass)):

pandas/core/generic.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3556,7 +3556,7 @@ def _iget_item_cache(self, item):
35563556
def _box_item_values(self, key, values):
35573557
raise AbstractMethodError(self)
35583558

3559-
def _slice(self, slobj, axis=0, kind=None):
3559+
def _slice(self, slobj: slice, axis=0, kind=None):
35603560
"""
35613561
Construct a slice of this container.
35623562
@@ -6183,8 +6183,6 @@ def fillna(
61836183
axis = 0
61846184
axis = self._get_axis_number(axis)
61856185

6186-
from pandas import DataFrame
6187-
61886186
if value is None:
61896187

61906188
if self._is_mixed_type and axis == 1:
@@ -6247,7 +6245,7 @@ def fillna(
62476245
new_data = self._data.fillna(
62486246
value=value, limit=limit, inplace=inplace, downcast=downcast
62496247
)
6250-
elif isinstance(value, DataFrame) and self.ndim == 2:
6248+
elif isinstance(value, ABCDataFrame) and self.ndim == 2:
62516249
new_data = self.where(self.notna(), value)
62526250
else:
62536251
raise ValueError("invalid fill value with a %s" % type(value))

pandas/core/groupby/groupby.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ class providing the base-class of operations.
2929
from pandas.core.dtypes.cast import maybe_downcast_to_dtype
3030
from pandas.core.dtypes.common import (
3131
ensure_float,
32+
is_datetime64_dtype,
3233
is_datetime64tz_dtype,
3334
is_extension_array_dtype,
35+
is_integer_dtype,
3436
is_numeric_dtype,
37+
is_object_dtype,
3538
is_scalar,
3639
)
3740
from pandas.core.dtypes.missing import isna, notna
3841

39-
from pandas.api.types import is_datetime64_dtype, is_integer_dtype, is_object_dtype
4042
import pandas.core.algorithms as algorithms
4143
from pandas.core.arrays import Categorical
4244
from pandas.core.base import (
@@ -343,7 +345,7 @@ class _GroupBy(PandasObject, SelectionMixin):
343345

344346
def __init__(
345347
self,
346-
obj,
348+
obj: NDFrame,
347349
keys=None,
348350
axis=0,
349351
level=None,
@@ -360,8 +362,8 @@ def __init__(
360362

361363
self._selection = selection
362364

363-
if isinstance(obj, NDFrame):
364-
obj._consolidate_inplace()
365+
assert isinstance(obj, NDFrame), type(obj)
366+
obj._consolidate_inplace()
365367

366368
self.level = level
367369

0 commit comments

Comments
 (0)