Skip to content

CLN: remove ABCIndex #38055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 26, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pandas/core/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
)
from pandas.core.dtypes.generic import (
ABCExtensionArray,
ABCIndex,
ABCIndexClass,
ABCMultiIndex,
ABCSeries,
Expand Down Expand Up @@ -421,7 +420,9 @@ def isin(comps: AnyArrayLike, values: AnyArrayLike) -> np.ndarray:
f"to isin(), you passed a [{type(values).__name__}]"
)

if not isinstance(values, (ABCIndex, ABCSeries, ABCExtensionArray, np.ndarray)):
if not isinstance(
values, (ABCIndexClass, ABCSeries, ABCExtensionArray, np.ndarray)
):
values = construct_1d_object_array_from_listlike(list(values))
# TODO: could use ensure_arraylike here

Expand Down
13 changes: 5 additions & 8 deletions pandas/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@
is_extension_array_dtype,
is_integer,
)
from pandas.core.dtypes.generic import (
ABCExtensionArray,
ABCIndex,
ABCIndexClass,
ABCSeries,
)
from pandas.core.dtypes.generic import ABCExtensionArray, ABCIndexClass, ABCSeries
from pandas.core.dtypes.inference import iterable_not_string
from pandas.core.dtypes.missing import isna, isnull, notnull # noqa

Expand Down Expand Up @@ -105,7 +100,7 @@ def is_bool_indexer(key: Any) -> bool:
check_array_indexer : Check that `key` is a valid array to index,
and convert to an ndarray.
"""
if isinstance(key, (ABCSeries, np.ndarray, ABCIndex)) or (
if isinstance(key, (ABCSeries, np.ndarray, ABCIndexClass)) or (
is_array_like(key) and is_extension_array_dtype(key.dtype)
):
if key.dtype == np.object_:
Expand Down Expand Up @@ -471,7 +466,9 @@ def convert_to_list_like(
Convert list-like or scalar input to list-like. List, numpy and pandas array-like
inputs are returned unmodified whereas others are converted to list.
"""
if isinstance(values, (list, np.ndarray, ABCIndex, ABCSeries, ABCExtensionArray)):
if isinstance(
values, (list, np.ndarray, ABCIndexClass, ABCSeries, ABCExtensionArray)
):
# np.ndarray resolving as Any gives a false positive
return values # type: ignore[return-value]
elif isinstance(values, abc.Iterable) and not isinstance(values, str):
Expand Down
1 change: 0 additions & 1 deletion pandas/core/dtypes/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def _check(cls, inst) -> bool:
return meta(name, tuple(), dct)


ABCIndex = create_pandas_abc_type("ABCIndex", "_typ", ("index",))
ABCInt64Index = create_pandas_abc_type("ABCInt64Index", "_typ", ("int64index",))
ABCUInt64Index = create_pandas_abc_type("ABCUInt64Index", "_typ", ("uint64index",))
ABCRangeIndex = create_pandas_abc_type("ABCRangeIndex", "_typ", ("rangeindex",))
Expand Down
16 changes: 13 additions & 3 deletions pandas/core/indexes/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
is_scalar,
)
from pandas.core.dtypes.concat import concat_compat
from pandas.core.dtypes.generic import ABCIndex, ABCSeries
from pandas.core.dtypes.generic import ABCSeries

from pandas.core.arrays import DatetimeArray, PeriodArray, TimedeltaArray
from pandas.core.arrays.datetimelike import DatetimeLikeArrayMixin
Expand Down Expand Up @@ -53,10 +53,20 @@ def _join_i8_wrapper(joinf, with_indexers: bool = True):
# error: 'staticmethod' used with a non-method
@staticmethod # type: ignore[misc]
def wrapper(left, right):
if isinstance(left, (np.ndarray, ABCIndex, ABCSeries, DatetimeLikeArrayMixin)):
# Note: these only get called with left.dtype == right.dtype
if isinstance(
left, (np.ndarray, DatetimeIndexOpsMixin, ABCSeries, DatetimeLikeArrayMixin)
):
left = left.view("i8")
if isinstance(right, (np.ndarray, ABCIndex, ABCSeries, DatetimeLikeArrayMixin)):
else:
raise TypeError(type(left))
if isinstance(
right,
(np.ndarray, DatetimeIndexOpsMixin, ABCSeries, DatetimeLikeArrayMixin),
):
right = right.view("i8")
else:
raise TypeError(type(right))

results = joinf(left, right)
if with_indexers:
Expand Down
8 changes: 3 additions & 5 deletions pandas/core/ops/array_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
is_object_dtype,
is_scalar,
)
from pandas.core.dtypes.generic import ABCExtensionArray, ABCIndex, ABCSeries
from pandas.core.dtypes.generic import ABCExtensionArray, ABCIndexClass, ABCSeries
from pandas.core.dtypes.missing import isna, notna

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

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

if isinstance(y, (ABCSeries, ABCIndex)):
if isinstance(y, (ABCSeries, ABCIndexClass)):
y = y._values

if x.shape != y.shape:
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/dtypes/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class TestABCClasses:
timedelta_array = pd.core.arrays.TimedeltaArray(timedelta_index)

def test_abc_types(self):
assert isinstance(pd.Index(["a", "b", "c"]), gt.ABCIndex)
assert isinstance(pd.Int64Index([1, 2, 3]), gt.ABCInt64Index)
assert isinstance(pd.UInt64Index([1, 2, 3]), gt.ABCUInt64Index)
assert isinstance(pd.Float64Index([1, 2, 3]), gt.ABCFloat64Index)
Expand Down