From 8513db218ce8b9a7e035f03917f11ec88a5c8834 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Fri, 6 Dec 2019 05:03:30 -0800 Subject: [PATCH] DEPR: ufunc.outer (#30104) --- doc/source/whatsnew/v1.0.0.rst | 1 + pandas/core/series.py | 10 ++-------- pandas/tests/series/test_ufunc.py | 6 ++---- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/doc/source/whatsnew/v1.0.0.rst b/doc/source/whatsnew/v1.0.0.rst index 5e2eaa6ca4a941..b93856db6ba8d0 100644 --- a/doc/source/whatsnew/v1.0.0.rst +++ b/doc/source/whatsnew/v1.0.0.rst @@ -604,6 +604,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more. - Removed the previously deprecated :meth:`Series.to_dense`, :meth:`DataFrame.to_dense` (:issue:`26684`) - Removed the previously deprecated :meth:`Index.dtype_str`, use ``str(index.dtype)`` instead (:issue:`27106`) - :meth:`Categorical.ravel` returns a :class:`Categorical` instead of a ``ndarray`` (:issue:`27199`) +- The 'outer' method on Numpy ufuncs, e.g. ``np.subtract.outer`` operating on :class:`Series` objects is no longer supported, and will raise ``NotImplementedError`` (:issue:`27198`) - Removed previously deprecated :meth:`Series.get_dtype_counts` and :meth:`DataFrame.get_dtype_counts` (:issue:`27145`) - Changed the default ``fill_value`` in :meth:`Categorical.take` from ``True`` to ``False`` (:issue:`20841`) - Changed the default value for the `raw` argument in :func:`Series.rolling().apply() `, :func:`DataFrame.rolling().apply() `, diff --git a/pandas/core/series.py b/pandas/core/series.py index efa3d33a2a79a0..9795412920efd3 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -684,14 +684,8 @@ def construct_return(result): elif result.ndim > 1: # e.g. np.subtract.outer if method == "outer": - msg = ( - "outer method for ufunc {} is not implemented on " - "pandas objects. Returning an ndarray, but in the " - "future this will raise a 'NotImplementedError'. " - "Consider explicitly converting the Series " - "to an array with '.array' first." - ) - warnings.warn(msg.format(ufunc), FutureWarning, stacklevel=3) + # GH#27198 + raise NotImplementedError return result return self._constructor(result, index=index, name=name, copy=False) diff --git a/pandas/tests/series/test_ufunc.py b/pandas/tests/series/test_ufunc.py index 92d72706f3dec4..120eaeaf785b07 100644 --- a/pandas/tests/series/test_ufunc.py +++ b/pandas/tests/series/test_ufunc.py @@ -299,7 +299,5 @@ def test_outer(): s = pd.Series([1, 2, 3]) o = np.array([1, 2, 3]) - with tm.assert_produces_warning(FutureWarning): - result = np.subtract.outer(s, o) - expected = np.array([[0, -1, -2], [1, 0, -1], [2, 1, 0]], dtype=np.dtype("int64")) - tm.assert_numpy_array_equal(result, expected) + with pytest.raises(NotImplementedError): + np.subtract.outer(s, o)