From a4db51bf79ae115158de97cf22078823d2946a5b Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Sun, 10 Mar 2019 14:20:16 +0100 Subject: [PATCH] Clean up ufuncs post numpy bump --- pandas/core/arrays/sparse.py | 9 --------- pandas/core/sparse/frame.py | 6 ------ pandas/core/sparse/series.py | 20 -------------------- 3 files changed, 35 deletions(-) diff --git a/pandas/core/arrays/sparse.py b/pandas/core/arrays/sparse.py index ecc06db2bd07b..926ed6a829a6d 100644 --- a/pandas/core/arrays/sparse.py +++ b/pandas/core/arrays/sparse.py @@ -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 @@ -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): diff --git a/pandas/core/sparse/frame.py b/pandas/core/sparse/frame.py index bf1cec7571f4d..0320da6d9a48d 100644 --- a/pandas/core/sparse/frame.py +++ b/pandas/core/sparse/frame.py @@ -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, diff --git a/pandas/core/sparse/series.py b/pandas/core/sparse/series.py index 3f95acdbfb42c..3814d8bb66635 100644 --- a/pandas/core/sparse/series.py +++ b/pandas/core/sparse/series.py @@ -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):