From dad817ac81510095a89d5c5334b38425b93adbf2 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Wed, 28 Sep 2022 10:38:43 -0700 Subject: [PATCH 1/3] BUG: EWM(online) not raising NotImplementedError for unsupported --- doc/source/whatsnew/v1.6.0.rst | 1 + pandas/core/window/ewm.py | 10 +++++----- pandas/tests/window/test_online.py | 10 ++++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/doc/source/whatsnew/v1.6.0.rst b/doc/source/whatsnew/v1.6.0.rst index 566e3d7c66b79..7c2fde307f0d1 100644 --- a/doc/source/whatsnew/v1.6.0.rst +++ b/doc/source/whatsnew/v1.6.0.rst @@ -237,6 +237,7 @@ Plotting Groupby/resample/rolling ^^^^^^^^^^^^^^^^^^^^^^^^ +- Bug in :class:`.ExponentialMovingWindow` with ``online`` didn't raise a ``NotImplementedError`` for unsupported operations (:issue:`?`) - Bug in :meth:`DataFrameGroupBy.sample` raises ``ValueError`` when the object is empty (:issue:`48459`) - diff --git a/pandas/core/window/ewm.py b/pandas/core/window/ewm.py index 6fae119bffdf1..297febe724019 100644 --- a/pandas/core/window/ewm.py +++ b/pandas/core/window/ewm.py @@ -967,10 +967,10 @@ def reset(self) -> None: self._mean.reset() def aggregate(self, func, *args, **kwargs): - return NotImplementedError + raise NotImplementedError("aggregate is not implemented.") def std(self, bias: bool = False, *args, **kwargs): - return NotImplementedError + raise NotImplementedError("std is not implemented.") def corr( self, @@ -979,7 +979,7 @@ def corr( numeric_only: bool = False, **kwargs, ): - return NotImplementedError + raise NotImplementedError("corr is not implemented.") def cov( self, @@ -989,10 +989,10 @@ def cov( numeric_only: bool = False, **kwargs, ): - return NotImplementedError + raise NotImplementedError("cov is not implemented.") def var(self, bias: bool = False, *args, **kwargs): - return NotImplementedError + raise NotImplementedError("var is not implemented.") def mean(self, *args, update=None, update_times=None, **kwargs): """ diff --git a/pandas/tests/window/test_online.py b/pandas/tests/window/test_online.py index 88f462869d8b6..cce46526884a6 100644 --- a/pandas/tests/window/test_online.py +++ b/pandas/tests/window/test_online.py @@ -103,3 +103,13 @@ def test_update_times_mean( tm.assert_equal(result, expected.tail(3)) online_ewm.reset() + + @pytest.mark.parametrize("method", ["aggregate", "std", "corr", "cov", "var"]) + def test_ewm_notimplementederror_raises(self, method): + ser = Series(range(10)) + kwargs = {} + if method == "aggregate": + kwargs["func"] = lambda x: x + + with pytest.raises(NotImplementedError, match=".* is not implemented."): + getattr(ser.ewm(1).online(), method)(**kwargs) From 8cfe0b5d47d864aed27ac929c4a6997318472d85 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Wed, 28 Sep 2022 10:40:40 -0700 Subject: [PATCH 2/3] add pr number --- doc/source/whatsnew/v1.6.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.6.0.rst b/doc/source/whatsnew/v1.6.0.rst index 7c2fde307f0d1..d38cb15816ff9 100644 --- a/doc/source/whatsnew/v1.6.0.rst +++ b/doc/source/whatsnew/v1.6.0.rst @@ -237,7 +237,7 @@ Plotting Groupby/resample/rolling ^^^^^^^^^^^^^^^^^^^^^^^^ -- Bug in :class:`.ExponentialMovingWindow` with ``online`` didn't raise a ``NotImplementedError`` for unsupported operations (:issue:`?`) +- Bug in :class:`.ExponentialMovingWindow` with ``online`` didn't raise a ``NotImplementedError`` for unsupported operations (:issue:`48834`) - Bug in :meth:`DataFrameGroupBy.sample` raises ``ValueError`` when the object is empty (:issue:`48459`) - From bf4de52d8878ad38db146feb0dbc2e41f0ab68de Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Wed, 28 Sep 2022 15:52:03 -0700 Subject: [PATCH 3/3] grammar --- doc/source/whatsnew/v1.6.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.6.0.rst b/doc/source/whatsnew/v1.6.0.rst index d38cb15816ff9..108566c8866ee 100644 --- a/doc/source/whatsnew/v1.6.0.rst +++ b/doc/source/whatsnew/v1.6.0.rst @@ -237,7 +237,7 @@ Plotting Groupby/resample/rolling ^^^^^^^^^^^^^^^^^^^^^^^^ -- Bug in :class:`.ExponentialMovingWindow` with ``online`` didn't raise a ``NotImplementedError`` for unsupported operations (:issue:`48834`) +- Bug in :class:`.ExponentialMovingWindow` with ``online`` not raising a ``NotImplementedError`` for unsupported operations (:issue:`48834`) - Bug in :meth:`DataFrameGroupBy.sample` raises ``ValueError`` when the object is empty (:issue:`48459`) -