Skip to content

Commit 6ef5b4b

Browse files
authored
CLN: remove ABCIndex (#38055)
1 parent 03b9ad8 commit 6ef5b4b

File tree

5 files changed

+18
-19
lines changed

5 files changed

+18
-19
lines changed

pandas/core/common.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@
2424
is_extension_array_dtype,
2525
is_integer,
2626
)
27-
from pandas.core.dtypes.generic import (
28-
ABCExtensionArray,
29-
ABCIndex,
30-
ABCIndexClass,
31-
ABCSeries,
32-
)
27+
from pandas.core.dtypes.generic import ABCExtensionArray, ABCIndexClass, ABCSeries
3328
from pandas.core.dtypes.inference import iterable_not_string
3429
from pandas.core.dtypes.missing import isna, isnull, notnull # noqa
3530

@@ -105,7 +100,7 @@ def is_bool_indexer(key: Any) -> bool:
105100
check_array_indexer : Check that `key` is a valid array to index,
106101
and convert to an ndarray.
107102
"""
108-
if isinstance(key, (ABCSeries, np.ndarray, ABCIndex)) or (
103+
if isinstance(key, (ABCSeries, np.ndarray, ABCIndexClass)) or (
109104
is_array_like(key) and is_extension_array_dtype(key.dtype)
110105
):
111106
if key.dtype == np.object_:
@@ -471,7 +466,9 @@ def convert_to_list_like(
471466
Convert list-like or scalar input to list-like. List, numpy and pandas array-like
472467
inputs are returned unmodified whereas others are converted to list.
473468
"""
474-
if isinstance(values, (list, np.ndarray, ABCIndex, ABCSeries, ABCExtensionArray)):
469+
if isinstance(
470+
values, (list, np.ndarray, ABCIndexClass, ABCSeries, ABCExtensionArray)
471+
):
475472
# np.ndarray resolving as Any gives a false positive
476473
return values # type: ignore[return-value]
477474
elif isinstance(values, abc.Iterable) and not isinstance(values, str):

pandas/core/dtypes/generic.py

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ def _check(cls, inst) -> bool:
2323
return meta(name, tuple(), dct)
2424

2525

26-
ABCIndex = create_pandas_abc_type("ABCIndex", "_typ", ("index",))
2726
ABCInt64Index = create_pandas_abc_type("ABCInt64Index", "_typ", ("int64index",))
2827
ABCUInt64Index = create_pandas_abc_type("ABCUInt64Index", "_typ", ("uint64index",))
2928
ABCRangeIndex = create_pandas_abc_type("ABCRangeIndex", "_typ", ("rangeindex",))

pandas/core/indexes/datetimelike.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
is_scalar,
2323
)
2424
from pandas.core.dtypes.concat import concat_compat
25-
from pandas.core.dtypes.generic import ABCIndex, ABCSeries
25+
from pandas.core.dtypes.generic import ABCSeries
2626

2727
from pandas.core.arrays import DatetimeArray, PeriodArray, TimedeltaArray
2828
from pandas.core.arrays.datetimelike import DatetimeLikeArrayMixin
@@ -53,16 +53,22 @@ def _join_i8_wrapper(joinf, with_indexers: bool = True):
5353
# error: 'staticmethod' used with a non-method
5454
@staticmethod # type: ignore[misc]
5555
def wrapper(left, right):
56-
if isinstance(left, (np.ndarray, ABCIndex, ABCSeries, DatetimeLikeArrayMixin)):
56+
# Note: these only get called with left.dtype == right.dtype
57+
if isinstance(
58+
left, (np.ndarray, DatetimeIndexOpsMixin, ABCSeries, DatetimeLikeArrayMixin)
59+
):
5760
left = left.view("i8")
58-
if isinstance(right, (np.ndarray, ABCIndex, ABCSeries, DatetimeLikeArrayMixin)):
61+
if isinstance(
62+
right,
63+
(np.ndarray, DatetimeIndexOpsMixin, ABCSeries, DatetimeLikeArrayMixin),
64+
):
5965
right = right.view("i8")
6066

6167
results = joinf(left, right)
6268
if with_indexers:
6369
# dtype should be timedelta64[ns] for TimedeltaIndex
6470
# and datetime64[ns] for DatetimeIndex
65-
dtype = left.dtype.base
71+
dtype = cast(np.dtype, left.dtype).base
6672

6773
join_index, left_indexer, right_indexer = results
6874
join_index = join_index.view(dtype)

pandas/core/ops/array_ops.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
is_object_dtype,
2828
is_scalar,
2929
)
30-
from pandas.core.dtypes.generic import ABCExtensionArray, ABCIndex, ABCSeries
30+
from pandas.core.dtypes.generic import ABCExtensionArray, ABCIndexClass, ABCSeries
3131
from pandas.core.dtypes.missing import isna, notna
3232

3333
from pandas.core.ops import missing
@@ -40,13 +40,11 @@ def comp_method_OBJECT_ARRAY(op, x, y):
4040
if isinstance(y, list):
4141
y = construct_1d_object_array_from_listlike(y)
4242

43-
if isinstance(y, (np.ndarray, ABCSeries, ABCIndex)):
44-
# Note: these checks can be for ABCIndex and not ABCIndexClass
45-
# because that is the only object-dtype class.
43+
if isinstance(y, (np.ndarray, ABCSeries, ABCIndexClass)):
4644
if not is_object_dtype(y.dtype):
4745
y = y.astype(np.object_)
4846

49-
if isinstance(y, (ABCSeries, ABCIndex)):
47+
if isinstance(y, (ABCSeries, ABCIndexClass)):
5048
y = y._values
5149

5250
if x.shape != y.shape:

pandas/tests/dtypes/test_generic.py

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class TestABCClasses:
2222
timedelta_array = pd.core.arrays.TimedeltaArray(timedelta_index)
2323

2424
def test_abc_types(self):
25-
assert isinstance(pd.Index(["a", "b", "c"]), gt.ABCIndex)
2625
assert isinstance(pd.Int64Index([1, 2, 3]), gt.ABCInt64Index)
2726
assert isinstance(pd.UInt64Index([1, 2, 3]), gt.ABCUInt64Index)
2827
assert isinstance(pd.Float64Index([1, 2, 3]), gt.ABCFloat64Index)

0 commit comments

Comments
 (0)