Skip to content
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

Clean up ufuncs post numpy bump #26606

Merged
merged 1 commit into from
Jun 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 0 additions & 9 deletions pandas/core/arrays/sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,6 @@ class SparseArray(PandasObject, ExtensionArray, ExtensionOpsMixin):
Whether to explicitly copy the incoming `data` array.
"""

__array_priority__ = 15
_pandas_ftype = 'sparse'
_subtyp = 'sparse_array' # register ABCSparseArray

Expand Down Expand Up @@ -1639,14 +1638,6 @@ def T(self):
# Ufuncs
# ------------------------------------------------------------------------

def __array_wrap__(self, array, context=None):
from pandas.core.dtypes.generic import ABCSparseSeries

ufunc, inputs, _ = context
inputs = tuple(x.to_dense() if isinstance(x, ABCSparseSeries) else x
for x in inputs)
return self.__array_ufunc__(ufunc, '__call__', *inputs)

_HANDLED_TYPES = (np.ndarray, numbers.Number)

def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
Expand Down
6 changes: 0 additions & 6 deletions pandas/core/sparse/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,6 @@ def _init_spmatrix(self, data, index, columns, dtype=None,
def to_coo(self):
return SparseFrameAccessor(self).to_coo()

def __array_wrap__(self, result):
return self._constructor(
result, index=self.index, columns=self.columns,
default_kind=self._default_kind,
default_fill_value=self._default_fill_value).__finalize__(self)

def __getstate__(self):
# pickling
return dict(_typ=self._typ, _subtyp=self._subtyp, _data=self._data,
Expand Down
20 changes: 0 additions & 20 deletions pandas/core/sparse/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,26 +124,6 @@ def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
fill_value=result.fill_value,
copy=False).__finalize__(self)

def __array_wrap__(self, result, context=None):
"""
Gets called prior to a ufunc (and after)

See SparseArray.__array_wrap__ for detail.
"""
result = self.values.__array_wrap__(result, context=context)
return self._constructor(result, index=self.index,
sparse_index=self.sp_index,
fill_value=result.fill_value,
copy=False).__finalize__(self)

def __array_finalize__(self, obj):
"""
Gets called after any ufunc or other array operations, necessary
to pass on the index.
"""
self.name = getattr(obj, 'name', None)
self.fill_value = getattr(obj, 'fill_value', None)

# unary ops
# TODO: See if this can be shared
def __pos__(self):
Expand Down