Skip to content

Commit 6bc1cf4

Browse files
jbrockmendeljreback
authored andcommitted
Remove unused SparseArray code (pandas-dev#27269)
1 parent af5b2a2 commit 6bc1cf4

File tree

2 files changed

+0
-48
lines changed

2 files changed

+0
-48
lines changed

Diff for: pandas/core/arrays/sparse.py

-1
Original file line numberDiff line numberDiff line change
@@ -1774,7 +1774,6 @@ def sparse_arithmetic_method(self, other):
17741774
else:
17751775
other = np.asarray(other)
17761776
with np.errstate(all="ignore"):
1777-
# TODO: delete sparse stuff in core/ops.py
17781777
# TODO: look into _wrap_result
17791778
if len(self) != len(other):
17801779
raise AssertionError(

Diff for: pandas/core/ops/__init__.py

-47
Original file line numberDiff line numberDiff line change
@@ -1401,12 +1401,6 @@ def _get_method_wrappers(cls):
14011401
arith_special = _arith_method_SERIES
14021402
comp_special = _comp_method_SERIES
14031403
bool_special = _bool_method_SERIES
1404-
elif issubclass(cls, ABCSparseArray):
1405-
arith_flex = None
1406-
comp_flex = None
1407-
arith_special = _arith_method_SPARSE_ARRAY
1408-
comp_special = _arith_method_SPARSE_ARRAY
1409-
bool_special = _arith_method_SPARSE_ARRAY
14101404
elif issubclass(cls, ABCDataFrame):
14111405
# Same for DataFrame and SparseDataFrame
14121406
arith_flex = _arith_method_FRAME
@@ -2336,47 +2330,6 @@ def _sparse_series_op(left, right, op, name):
23362330
return left._constructor(result, index=new_index, name=new_name)
23372331

23382332

2339-
def _arith_method_SPARSE_ARRAY(cls, op, special):
2340-
"""
2341-
Wrapper function for Series arithmetic operations, to avoid
2342-
code duplication.
2343-
"""
2344-
op_name = _get_op_name(op, special)
2345-
2346-
def wrapper(self, other):
2347-
from pandas.core.arrays.sparse.array import (
2348-
SparseArray,
2349-
_sparse_array_op,
2350-
_wrap_result,
2351-
_get_fill,
2352-
)
2353-
2354-
if isinstance(other, np.ndarray):
2355-
if len(self) != len(other):
2356-
raise AssertionError(
2357-
"length mismatch: {self} vs. {other}".format(
2358-
self=len(self), other=len(other)
2359-
)
2360-
)
2361-
if not isinstance(other, SparseArray):
2362-
dtype = getattr(other, "dtype", None)
2363-
other = SparseArray(other, fill_value=self.fill_value, dtype=dtype)
2364-
return _sparse_array_op(self, other, op, op_name)
2365-
elif is_scalar(other):
2366-
with np.errstate(all="ignore"):
2367-
fill = op(_get_fill(self), np.asarray(other))
2368-
result = op(self.sp_values, other)
2369-
2370-
return _wrap_result(op_name, result, self.sp_index, fill)
2371-
else: # pragma: no cover
2372-
raise TypeError(
2373-
"operation with {other} not supported".format(other=type(other))
2374-
)
2375-
2376-
wrapper.__name__ = op_name
2377-
return wrapper
2378-
2379-
23802333
def maybe_dispatch_ufunc_to_dunder_op(
23812334
self: ArrayLike, ufunc: Callable, method: str, *inputs: ArrayLike, **kwargs: Any
23822335
):

0 commit comments

Comments
 (0)