Skip to content

[MRG] Remove class support check estimator and parametrize_with_checks #17134

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

Merged

Conversation

NicolasHug
Copy link
Member

No description provided.

@jnothman
Copy link
Member

jnothman commented May 6, 2020

Still WIP?

@NicolasHug NicolasHug changed the title [WIP] Remove class support check estimator and parametrize_with_checks [MRG] Remove class support check estimator and parametrize_with_checks May 6, 2020
@NicolasHug
Copy link
Member Author

ready now!

@NicolasHug
Copy link
Member Author

@rth @thomasjpfan this should slightly ease #16963 and the strict mode PRs

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @NicolasHug !

This is a change I wanted to see in a while.

The "Checking scikit-learn compatibility of an estimator" section of examples/release_highlights/plot_release_highlights_0_22_0.py may need to be updated.

# TODO: remove class support in 0.24 and update docstrings
msg = ("Passing a class is deprecated since version 0.23 "
"and won't be supported in 0.24."
msg = ("Passing a class was deprecated in version 0.23 "
Copy link
Member

@thomasjpfan thomasjpfan May 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think we normally keep the deprecation warning version in the error message. Can this be:

Starting from 0.24, only instances are supported.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'll remove if others feel the same way. No strong opinion on my side, I just thought it might be useful since we only went for a 1 version deprecation cycle on this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thoughts on this @rth?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starting from 0.24, only instances are supported for the "estimators" parameter.

Yes +1 for this error message, mostly because it tells the user what to do when they get this error. It could be a TypeError instead of a ValueError maybe as well?

# got a class
msg = ("Passing a class is deprecated since version 0.23 "
"and won't be supported in 0.24."
msg = ("Passing a class was deprecated in version 0.23 "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very welcome! There is a slight risk that merging this now would make releasing bugfixes for 0.23.1 slightly more difficult, but I think being able to move forward on the related PRs is worth it.

LGTM, thanks!

@@ -2591,14 +2555,10 @@ def check_estimators_data_not_an_array(name, estimator_orig, X, y, obj_type):


def check_parameters_default_constructible(name, Estimator):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename it to estimator or do you think it would be considered an API breakage?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah it's not ideal but I'm concerned about backward compat :/

# only accept instances, not classes
Estimator = Estimator.__class__

Estimator = Estimator.__class__
Copy link
Member

@rth rth May 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would actually fail in mypy. The reason it doesn't currently is that conda activate fails, and the the CI step silently is marked as successful. So the linting CI job is broken. Fix in #17177

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure?

mypy --ignore-missing-import sklearn passes one this branch (v 0.770)

I've had mypy and linting issues on PRs recently so it seemed to "work" fine

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, yes you are right, it just installs everything in the main env. Well I would have though that it would error but nevermind.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need to fix the activation issues in #17177 though.

I though it was broken because I keep getting a few new mypy errors with code on master (that I haven't touched) occasionally.

@NicolasHug
Copy link
Member Author

Does this have your blessing @thomasjpfan?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants