Skip to content

Commit

Permalink
DEPR: ufunc.outer (pandas-dev#30104)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel authored and proost committed Dec 19, 2019
1 parent faa642a commit 6eea19c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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() <pandas.core.window.Rolling.apply>`, :func:`DataFrame.rolling().apply() <pandas.core.window.Rolling.apply>`,
Expand Down
10 changes: 2 additions & 8 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 2 additions & 4 deletions pandas/tests/series/test_ufunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 6eea19c

Please sign in to comment.