-
Notifications
You must be signed in to change notification settings - Fork 540
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
Avoid hard import of sklearn in base module. #5663
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you verify if IPython handles this
_repr_mimebundle_
function returningNone
in the same way as it handles this function not existing? In other words, is the notebook output without sklearn worse than the output before #5630?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 don't know the answer, but I think you could return
{"text/plain": repr(self)}
in the case of scikit-learn not being installed and that would lead to the same thing being displayed as now. The way the mimebundles work is that you can return several (text, html, png, video, ...) and the UI then chooses the one it things is best. So if we only provide the text based on, it should always choose that?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 read the documentation on this and it interpreted the phrase "[i]f this returns something, other
_repr_*_
methods are ignored" to mean that if we returnNone
on this function we are not returning "something" so other functions should be used. I also ran some tests in a Jupyter notebook which seemed to confirm that. However, could confirm that. I don't think that returning{"text/plain": repr(self)}
is a good idea, because it seems that this function would take precedence over other potentially applicable functions. Which could lead to surprising behavior, especially when child classes try to specialize the representation in a meaningful way.@betatim Was there a specific reason that you chose to use
_repr_mimebundle_
as opposed to overriding_repr_html_
?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'm slightly revising my comment. I think returning
{"text/plain": repr(self)}
is a good idea as long as we use the_repr_mimebundle_
function, however, I'm wondering whether it wouldn't be be better to use_repr_html_
in the first 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.
I agree that it’s better to use
_repr_html_
for supporting only one special repr format.