Skip to content

Commit 3cebe30

Browse files
authored
CLN: remove ABCSparseArray (#33957)
1 parent 34959a2 commit 3cebe30

File tree

4 files changed

+6
-13
lines changed

4 files changed

+6
-13
lines changed

pandas/core/arrays/sparse/array.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
is_string_dtype,
3636
pandas_dtype,
3737
)
38-
from pandas.core.dtypes.generic import ABCIndexClass, ABCSeries, ABCSparseArray
38+
from pandas.core.dtypes.generic import ABCIndexClass, ABCSeries
3939
from pandas.core.dtypes.missing import isna, na_value_for_dtype, notna
4040

4141
import pandas.core.algorithms as algos
@@ -58,7 +58,7 @@
5858
_sparray_doc_kwargs = dict(klass="SparseArray")
5959

6060

61-
def _get_fill(arr: ABCSparseArray) -> np.ndarray:
61+
def _get_fill(arr: "SparseArray") -> np.ndarray:
6262
"""
6363
Create a 0-dim ndarray containing the fill value
6464
@@ -83,7 +83,7 @@ def _get_fill(arr: ABCSparseArray) -> np.ndarray:
8383

8484

8585
def _sparse_array_op(
86-
left: ABCSparseArray, right: ABCSparseArray, op: Callable, name: str
86+
left: "SparseArray", right: "SparseArray", op: Callable, name: str
8787
) -> Any:
8888
"""
8989
Perform a binary operation between two arrays.

pandas/core/dtypes/generic.py

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def _check(cls, inst) -> bool:
5656
ABCSeries = create_pandas_abc_type("ABCSeries", "_typ", ("series",))
5757
ABCDataFrame = create_pandas_abc_type("ABCDataFrame", "_typ", ("dataframe",))
5858

59-
ABCSparseArray = create_pandas_abc_type("ABCSparseArray", "_subtyp", ("sparse_array",))
6059
ABCCategorical = create_pandas_abc_type("ABCCategorical", "_typ", ("categorical"))
6160
ABCDatetimeArray = create_pandas_abc_type("ABCDatetimeArray", "_typ", ("datetimearray"))
6261
ABCTimedeltaArray = create_pandas_abc_type(

pandas/core/ops/methods.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
import operator
55

6-
from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries, ABCSparseArray
6+
from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries
77

88
from pandas.core.ops.roperator import (
99
radd,
@@ -225,10 +225,4 @@ def _create_methods(cls, arith_method, comp_method, bool_method, special):
225225

226226
def _add_methods(cls, new_methods):
227227
for name, method in new_methods.items():
228-
# For most methods, if we find that the class already has a method
229-
# of the same name, it is OK to over-write it. The exception is
230-
# inplace methods (__iadd__, __isub__, ...) for SparseArray, which
231-
# retain the np.ndarray versions.
232-
force = not (issubclass(cls, ABCSparseArray) and name.startswith("__i"))
233-
if force or name not in cls.__dict__:
234-
setattr(cls, name, method)
228+
setattr(cls, name, method)

pandas/tests/dtypes/test_generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_abc_types(self):
3535
assert isinstance(pd.Int64Index([1, 2, 3]), gt.ABCIndexClass)
3636
assert isinstance(pd.Series([1, 2, 3]), gt.ABCSeries)
3737
assert isinstance(self.df, gt.ABCDataFrame)
38-
assert isinstance(self.sparse_array, gt.ABCSparseArray)
38+
assert isinstance(self.sparse_array, gt.ABCExtensionArray)
3939
assert isinstance(self.categorical, gt.ABCCategorical)
4040

4141
assert isinstance(self.datetime_array, gt.ABCDatetimeArray)

0 commit comments

Comments
 (0)