-
-
Notifications
You must be signed in to change notification settings - Fork 26.1k
ENH Improves error message when experimental flag is not imported #23194
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
ENH Improves error message when experimental flag is not imported #23194
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Just wondering, in principle we could put all the logic in __getattr__
(checking if sklearn.experimental.enable_bla
is in sys.modules
) and remove the code from sklearn.experimental.enable_bla
, right?
The advantage would be that the experimental enabling logic in in a single place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm. Loic has a point if it's worth tackling
Yes, this is a good idea. I included your suggestion in: |
setattr(model_selection, "HalvingRandomSearchCV", HalvingRandomSearchCV) | ||
setattr(model_selection, "HalvingGridSearchCV", HalvingGridSearchCV) | ||
|
||
model_selection.__all__ += ["HalvingRandomSearchCV", "HalvingGridSearchCV"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The __all__
functionality has not been replicated in __getattr__
, is that on purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not consider __all__
. I do not think there is a way to replicate it in __getattr__
. PEP562 allows us to adjust dir
, but that does not influence __all__
or the import *
mechanism.
With that in mind, I reverted the commit that moves everything into __getattr__
.
This reverts commit b952e7a.
…ng_python_experimental_flag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I let @lesteve having a final look.
Merging, thanks! |
Reference Issues/PRs
Fixes #13964
What does this implement/fix? Explain your changes.
This PR uses PEP 562 to display a better error message when
IterativeImputer
,HalvingRandomSearchCV
, orHalvingGridSearchCV
is imported without the experimental import flag