8000 FutureWarning is not issued for deprecated class · Issue #15994 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

FutureWarning is not issued for deprecated class #15994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bsipocz opened this issue Dec 31, 2019 · 0 comments · Fixed by #25733
Closed

FutureWarning is not issued for deprecated class #15994

bsipocz opened this issue Dec 31, 2019 · 0 comments · Fixed by #25733
Labels

Comments

@bsipocz
Copy link
Contributor
bsipocz commented Dec 31, 2019

FutureWarning is not issued when using BaseNB as a baseclass but its __init__() is not called in the subclass, here: https://github.com/astroML/astroML/blob/master/astroML/classification/gmm_bayes.py#L15

In [1]: from astroML.classification import GMMBayes                                                                                                                                

In [2]: GMMBayes()                                                                                                                                                                 
Out[2]: GMMBayes(n_components=array([1]))

As the comment suggest in your deprecated decorator, overriding __new__ in the class decorator indeed solves this issue.

In [4]: from astroML.classification import GMMBayes                                                                                                                                

In [5]: GMMBayes()                                                                                                                                                                 
/Users/bsipocz/munka/devel/scikit-learn/sklearn/utils/deprecation.py:73: FutureWarning: Class BaseNB is deprecated; BaseNB is deprecated in version 0.22 and will be removed in version 0.24.
  warnings.warn(msg, category=FutureWarning)
Out[5]: GMMBayes(n_components=array([1]))

I'm happy to open a PR with the fix.

Also, relatedly, I wonder whether you would be interested in using a generic deprecation package instead. Basically we have the same functionality in astropy (I feel it's actually has more features e.g. this works there out of the box, it helps with arg renames/removals, etc.), there is also a deprecated decorator in matplotlib, and also a very basic one in numpy. I feel that having one for the wider ecosystem would be beneficial instead of the current system where we all roll our own.
At the numfocus summit I recall some interest from the mpl side, so I'm happy to get the ball rolling in this quoter if it's a thumb up from multiple projects.

Darwin-17.7.0-x86_64-i386-64bit
Python 3.7.5 (default, Nov 1 2019, 02:16:38)
[Clang 10.0.0 (clang-1000.11.45.5)]
NumPy 1.19.0.dev0+63ef78b
SciPy 1.4.1
Scikit-Learn 0.23.dev0

@bsipocz bsipocz changed the title FutureWarning is not issues for deprecated class FutureWarning is not issued for deprecated class Dec 31, 2019
@cmarmo cmarmo added the Needs Decision Requires decision label Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants
0