Skip to content

Commit e55c46e

Browse files
authored
CLN/TYP: remove unused (#46151)
1 parent 1f0c547 commit e55c46e

15 files changed

+42
-83
lines changed

pandas/_libs/algos.pyi

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -61,67 +61,48 @@ def nancorr_spearman(
6161

6262
# ----------------------------------------------------------------------
6363

64-
# ctypedef fused algos_t:
65-
# float64_t
66-
# float32_t
67-
# object
68-
# int64_t
69-
# int32_t
70-
# int16_t
71-
# int8_t
72-
# uint64_t
73-
# uint32_t
74-
# uint16_t
75-
# uint8_t
76-
7764
def validate_limit(nobs: int | None, limit=...) -> int: ...
7865
def pad(
79-
old: np.ndarray, # ndarray[algos_t]
80-
new: np.ndarray, # ndarray[algos_t]
66+
old: np.ndarray, # ndarray[numeric_object_t]
67+
new: np.ndarray, # ndarray[numeric_object_t]
8168
limit=...,
8269
) -> npt.NDArray[np.intp]: ... # np.ndarray[np.intp, ndim=1]
8370
def pad_inplace(
84-
values: np.ndarray, # algos_t[:]
71+
values: np.ndarray, # numeric_object_t[:]
8572
mask: np.ndarray, # uint8_t[:]
8673
limit=...,
8774
) -> None: ...
8875
def pad_2d_inplace(
89-
values: np.ndarray, # algos_t[:, :]
76+
values: np.ndarray, # numeric_object_t[:, :]
9077
mask: np.ndarray, # const uint8_t[:, :]
9178
limit=...,
9279
) -> None: ...
9380
def backfill(
94-
old: np.ndarray, # ndarray[algos_t]
95-
new: np.ndarray, # ndarray[algos_t]
81+
old: np.ndarray, # ndarray[numeric_object_t]
82+
new: np.ndarray, # ndarray[numeric_object_t]
9683
limit=...,
9784
) -> npt.NDArray[np.intp]: ... # np.ndarray[np.intp, ndim=1]
9885
def backfill_inplace(
99-
values: np.ndarray, # algos_t[:]
86+
values: np.ndarray, # numeric_object_t[:]
10087
mask: np.ndarray, # uint8_t[:]
10188
limit=...,
10289
) -> None: ...
10390
def backfill_2d_inplace(
104-
values: np.ndarray, # algos_t[:, :]
91+
values: np.ndarray, # numeric_object_t[:, :]
10592
mask: np.ndarray, # const uint8_t[:, :]
10693
limit=...,
10794
) -> None: ...
10895
def is_monotonic(
109-
arr: np.ndarray, # ndarray[algos_t, ndim=1]
96+
arr: np.ndarray, # ndarray[numeric_object_t, ndim=1]
11097
timelike: bool,
11198
) -> tuple[bool, bool, bool]: ...
11299

113100
# ----------------------------------------------------------------------
114101
# rank_1d, rank_2d
115102
# ----------------------------------------------------------------------
116103

117-
# ctypedef fused rank_t:
118-
# object
119-
# float64_t
120-
# uint64_t
121-
# int64_t
122-
123104
def rank_1d(
124-
values: np.ndarray, # ndarray[rank_t, ndim=1]
105+
values: np.ndarray, # ndarray[iu_64_floating_obj_t, ndim=1]
125106
labels: np.ndarray | None = ..., # const int64_t[:]=None
126107
is_datetimelike: bool = ...,
127108
ties_method=...,
@@ -130,7 +111,7 @@ def rank_1d(
130111
na_option=...,
131112
) -> np.ndarray: ... # np.ndarray[float64_t, ndim=1]
132113
def rank_2d(
133-
in_arr: np.ndarray, # ndarray[rank_t, ndim=2]
114+
in_arr: np.ndarray, # ndarray[iu_64_floating_obj_t, ndim=2]
134115
axis: int = ...,
135116
is_datetimelike: bool = ...,
136117
ties_method=...,

pandas/_libs/groupby.pyx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -475,19 +475,16 @@ def group_any_all(int8_t[:, ::1] out,
475475
# group_add, group_prod, group_var, group_mean, group_ohlc
476476
# ----------------------------------------------------------------------
477477

478-
ctypedef fused add_t:
479-
float64_t
480-
float32_t
481-
complex64_t
482-
complex128_t
483-
object
484-
485478
ctypedef fused mean_t:
486479
float64_t
487480
float32_t
488481
complex64_t
489482
complex128_t
490483

484+
ctypedef fused add_t:
485+
mean_t
486+
object
487+
491488

492489
@cython.wraparound(False)
493490
@cython.boundscheck(False)

pandas/_libs/hashtable.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ cnp.import_array()
2727

2828

2929
from pandas._libs cimport util
30+
from pandas._libs.dtypes cimport numeric_object_t
3031
from pandas._libs.khash cimport (
3132
KHASH_TRACE_DOMAIN,
3233
are_equivalent_float32_t,

pandas/_libs/hashtable_func_helper.pxi.in

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -301,19 +301,9 @@ cdef mode_{{dtype}}(const {{dtype}}_t[:] values, bint dropna):
301301

302302

303303
ctypedef fused htfunc_t:
304+
numeric_object_t
304305
complex128_t
305306
complex64_t
306-
float64_t
307-
float32_t
308-
uint64_t
309-
uint32_t
310-
uint16_t
311-
uint8_t
312-
int64_t
313-
int32_t
314-
int16_t
315-
int8_t
316-
object
317307

318308

319309
cpdef value_count(ndarray[htfunc_t] values, bint dropna):

pandas/core/arrays/_arrow_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from pandas.core.arrays.interval import VALID_CLOSED
77

88

9-
def pyarrow_array_to_numpy_and_mask(arr, dtype):
9+
def pyarrow_array_to_numpy_and_mask(arr, dtype: np.dtype):
1010
"""
1111
Convert a primitive pyarrow.Array to a numpy array and boolean mask based
1212
on the buffers of the Array.

pandas/core/arrays/_mixins.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,12 @@ def fillna(
313313
# TODO: check value is None
314314
# (for now) when self.ndim == 2, we assume axis=0
315315
func = missing.get_fill_func(method, ndim=self.ndim)
316-
new_values, _ = func(self._ndarray.T.copy(), limit=limit, mask=mask.T)
317-
new_values = new_values.T
316+
npvalues = self._ndarray.T.copy()
317+
func(npvalues, limit=limit, mask=mask.T)
318+
npvalues = npvalues.T
318319

319320
# TODO: PandasArray didn't used to copy, need tests for this
320-
new_values = self._from_backing_data(new_values)
321+
new_values = self._from_backing_data(npvalues)
321322
else:
322323
# fill with value
323324
new_values = self.copy()

pandas/core/arrays/base.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -789,8 +789,9 @@ def fillna(
789789
if mask.any():
790790
if method is not None:
791791
func = missing.get_fill_func(method)
792-
new_values, _ = func(self.astype(object), limit=limit, mask=mask)
793-
new_values = self._from_sequence(new_values, dtype=self.dtype)
792+
npvalues = self.astype(object)
793+
func(npvalues, limit=limit, mask=mask)
794+
new_values = self._from_sequence(npvalues, dtype=self.dtype)
794795
else:
795796
# fill with value
796797
new_values = self.copy()
@@ -1397,7 +1398,8 @@ def _reduce(self, name: str, *, skipna: bool = True, **kwargs):
13971398
__hash__: None # type: ignore[assignment]
13981399

13991400
# ------------------------------------------------------------------------
1400-
# Non-Optimized Default Methods
1401+
# Non-Optimized Default Methods; in the case of the private methods here,
1402+
# these are not guaranteeed to be stable across pandas versions.
14011403

14021404
def tolist(self) -> list:
14031405
"""
@@ -1510,10 +1512,11 @@ def _fill_mask_inplace(
15101512
ExtensionArray.fillna
15111513
"""
15121514
func = missing.get_fill_func(method)
1515+
npvalues = self.astype(object)
15131516
# NB: if we don't copy mask here, it may be altered inplace, which
15141517
# would mess up the `self[mask] = ...` below.
1515-
new_values, _ = func(self.astype(object), limit=limit, mask=mask.copy())
1516-
new_values = self._from_sequence(new_values, dtype=self.dtype)
1518+
func(npvalues, limit=limit, mask=mask.copy())
1519+
new_values = self._from_sequence(npvalues, dtype=self.dtype)
15171520
self[mask] = new_values[mask]
15181521
return
15191522

pandas/core/arrays/masked.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,10 @@ def fillna(
174174
if mask.any():
175175
if method is not None:
176176
func = missing.get_fill_func(method, ndim=self.ndim)
177-
new_values, new_mask = func(
178-
self._data.copy().T,
179-
limit=limit,
180-
mask=mask.copy().T,
181-
)
182-
return type(self)(new_values.T, new_mask.view(np.bool_).T)
177+
npvalues = self._data.copy().T
178+
new_mask = mask.copy().T
179+
func(npvalues, limit=limit, mask=new_mask)
180+
return type(self)(npvalues.T, new_mask.T)
183181
else:
184182
# fill with value
185183
new_values = self.copy()

pandas/core/arrays/numeric.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def __from_arrow__(
9595

9696
results = []
9797
for arr in chunks:
98-
data, mask = pyarrow_array_to_numpy_and_mask(arr, dtype=self.type)
98+
data, mask = pyarrow_array_to_numpy_and_mask(arr, dtype=self.numpy_dtype)
9999
num_arr = array_class(data.copy(), ~mask, copy=False)
100100
results.append(num_arr)
101101

pandas/core/dtypes/dtypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ def __from_arrow__(
10061006

10071007
results = []
10081008
for arr in chunks:
1009-
data, mask = pyarrow_array_to_numpy_and_mask(arr, dtype="int64")
1009+
data, mask = pyarrow_array_to_numpy_and_mask(arr, dtype=np.dtype(np.int64))
10101010
parr = PeriodArray(data.copy(), freq=self.freq, copy=False)
10111011
parr[~mask] = NaT
10121012
results.append(parr)

pandas/core/groupby/groupby.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3687,6 +3687,7 @@ def _reindex_output(
36873687
index, _ = MultiIndex.from_product(levels_list, names=names).sortlevel()
36883688

36893689
if self.as_index:
3690+
# Always holds for SeriesGroupBy unless GH#36507 is implemented
36903691
d = {
36913692
self.obj._get_axis_name(self.axis): index,
36923693
"copy": False,

pandas/core/groupby/grouper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ def _codes_and_uniques(self) -> tuple[np.ndarray, ArrayLike]:
680680
elif isinstance(self.grouping_vector, ops.BaseGrouper):
681681
# we have a list of groupers
682682
codes = self.grouping_vector.codes_info
683-
uniques = self.grouping_vector.result_arraylike
683+
uniques = self.grouping_vector.result_index._values
684684
else:
685685
# GH35667, replace dropna=False with na_sentinel=None
686686
if not self._dropna:

pandas/core/groupby/ops.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -868,21 +868,6 @@ def reconstructed_codes(self) -> list[np.ndarray]:
868868
ids, obs_ids, _ = self.group_info
869869
return decons_obs_group_ids(ids, obs_ids, self.shape, codes, xnull=True)
870870

871-
@final
872-
@cache_readonly
873-
def result_arraylike(self) -> ArrayLike:
874-
"""
875-
Analogous to result_index, but returning an ndarray/ExtensionArray
876-
allowing us to retain ExtensionDtypes not supported by Index.
877-
"""
878-
# TODO(ExtensionIndex): once Index supports arbitrary EAs, this can
879-
# be removed in favor of result_index
880-
if len(self.groupings) == 1:
881-
return self.groupings[0].group_arraylike
882-
883-
# result_index is MultiIndex
884-
return self.result_index._values
885-
886871
@cache_readonly
887872
def result_index(self) -> Index:
888873
if len(self.groupings) == 1:
@@ -1147,7 +1132,7 @@ def reconstructed_codes(self) -> list[np.ndarray]:
11471132
return [np.r_[0, np.flatnonzero(self.bins[1:] != self.bins[:-1]) + 1]]
11481133

11491134
@cache_readonly
1150-
def result_index(self):
1135+
def result_index(self) -> Index:
11511136
if len(self.binlabels) != 0 and isna(self.binlabels[0]):
11521137
return self.binlabels[1:]
11531138

pandas/core/reshape/reshape.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ def get_new_values(self, values, fill_value=None):
253253
else:
254254
if isinstance(dtype, ExtensionDtype):
255255
# GH#41875
256+
# We are assuming that fill_value can be held by this dtype,
257+
# unlike the non-EA case that promotes.
256258
cls = dtype.construct_array_type()
257259
new_values = cls._empty(result_shape, dtype=dtype)
258260
new_values[:] = fill_value

pandas/core/series.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5027,7 +5027,7 @@ def _replace_single(self, to_replace, method: str, inplace: bool, limit):
50275027
values._fill_mask_inplace(method, limit, mask)
50285028
else:
50295029
fill_f = missing.get_fill_func(method)
5030-
values, _ = fill_f(values, limit=limit, mask=mask)
5030+
fill_f(values, limit=limit, mask=mask)
50315031

50325032
if inplace:
50335033
return

0 commit comments

Comments
 (0)