From 46b100bd328b5363206d41097b54c11d00f99155 Mon Sep 17 00:00:00 2001 From: Olivier Grisel Date: Tue, 31 Dec 2019 16:27:00 +0100 Subject: [PATCH 1/3] Fix restore BaseNB._check_X without abstractmethod decoration --- doc/whats_new/v0.22.rst | 7 ++++--- sklearn/naive_bayes.py | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/doc/whats_new/v0.22.rst b/doc/whats_new/v0.22.rst index e36d7e925529d..9534ebcbf690b 100644 --- a/doc/whats_new/v0.22.rst +++ b/doc/whats_new/v0.22.rst @@ -61,9 +61,10 @@ Changelog :mod:`sklearn.naive_bayes` .......................... -- |Fix| removed abstract method `_check_X` from :class:`naive_bayes.BaseNB` - that could break downstream projects inheriting from this deprecated - public base class. :pr:`15996` by :user:`Brigitta Sipőcz `. +- |Fix| removed `abstractmethod` decorator for the method `_check_X` in + :class:`naive_bayes.BaseNB` that could break downstream projects inheriting + from this deprecated public base class. :pr:`15996` by + :user:`Brigitta Sipőcz `. :mod:`sklearn.semi_supervised` .............................. diff --git a/sklearn/naive_bayes.py b/sklearn/naive_bayes.py index d958645b178f6..361dbdec4c980 100644 --- a/sklearn/naive_bayes.py +++ b/sklearn/naive_bayes.py @@ -51,6 +51,14 @@ def _joint_log_likelihood(self, X): predict_proba and predict_log_proba. """ + def _check_X(self, X): + """To be overridden in subclasses with the actual checks.""" + # Note that this is not marked @abstractmethod as long as the + # deprecated public alias sklearn.naive_bayes.BayesNB exists + # (until 0.24) to preserve bacward compat for 3rd party projects + # with existing derived classes. + return X + def predict(self, X): """ Perform classification on an array of test vectors X. From 3f6a25f12f3f936e6d9668c910c02e702bc2d38f Mon Sep 17 00:00:00 2001 From: Olivier Grisel Date: Tue, 31 Dec 2019 16:37:26 +0100 Subject: [PATCH 2/3] typo [ci skip] --- sklearn/naive_bayes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/naive_bayes.py b/sklearn/naive_bayes.py index 361dbdec4c980..22bd339cbd6b0 100644 --- a/sklearn/naive_bayes.py +++ b/sklearn/naive_bayes.py @@ -55,7 +55,7 @@ def _check_X(self, X): """To be overridden in subclasses with the actual checks.""" # Note that this is not marked @abstractmethod as long as the # deprecated public alias sklearn.naive_bayes.BayesNB exists - # (until 0.24) to preserve bacward compat for 3rd party projects + # (until 0.24) to preserve backward compat for 3rd party projects # with existing derived classes. return X From 4ed0229802c522991d554bc354e6e737961c4f02 Mon Sep 17 00:00:00 2001 From: Hanmin Qin Date: Wed, 1 Jan 2020 11:10:57 +0800 Subject: [PATCH 3/3] Update v0.22.rst --- doc/whats_new/v0.22.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/whats_new/v0.22.rst b/doc/whats_new/v0.22.rst index 9534ebcbf690b..394fd6ee8203c 100644 --- a/doc/whats_new/v0.22.rst +++ b/doc/whats_new/v0.22.rst @@ -61,7 +61,7 @@ Changelog :mod:`sklearn.naive_bayes` .......................... -- |Fix| removed `abstractmethod` decorator for the method `_check_X` in +- |Fix| Removed `abstractmethod` decorator for the method `_check_X` in :class:`naive_bayes.BaseNB` that could break downstream projects inheriting from this deprecated public base class. :pr:`15996` by :user:`Brigitta Sipőcz `.