-
-
Notifications
You must be signed in to change notification settings - Fork 26.2k
ENH Adding a column to link each parameter docstring row in params table display #31564
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
base: main
Are you sure you want to change the base?
Conversation
TODO:
|
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.
Thanks for the PR @DeaMariaLeon.
I tested on the example you linked and it worked fine except for the C
parameter of LogisticRegression. Maybe the text fragment requires more than 1 character ?
Besides that, here are some comments
Thanks for the feedback! - the link to |
Docs have been built if someone wants to try again. |
The rendering looks good to me now. @jeremiedbb you can have another look. I'll go through the tests once more. |
This is soooo cool!! |
One comment: can we (should we), add "display: block;" to "a.param-doc-link, a.param-doc-link:link, a.param-doc-link:visited" so that its hovering on the cell rather than on the text that triggers the tooltip? It probably means that we should turn off the dashed underline on the text, because with "display: block" extends the underline too far out. |
edit: We could keep a dashed line... |
Very nice!! |
I'll like to keep the underline to alert users that there is something special about the this section of the diagram. I would still expect the text to have the hyperlink towards the documentation. Regarding text vs. cell, I don't have a strong opinion (maybe a slight one for the text since I find it easier to disable the tooltip by moving away from the string but it is rather subjective so using the cell is fine as well). |
+1 for keeping the link. Sometimes the rendering can be helpful (e.g. math). Furthermore, when browsing from a mobile device without a mouse, there is no way to get the tooltip so better keep a "click to navigate to doc" interaction in addition to the tooltip. |
The docs have been built. Gaël's feedback was added. |
I haven't reviewed the code, but from a user perspective, I think that it looks absolutely great, and it's definitely mergeable for me!! Thanks! |
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.
OK here is a pass on the code more in details. I propose some slight changes.
@glemaitre I think I addressed all your comments. |
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 on my side. It looks like a net improvement.
@jeremiedbb do you want to have a final look for merging the PR.
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.
Here's a new pass. It's great but I think that we can improve the usability a little bit, see my comments below.
"""Extract reference documentation from the NumPy source tree.""" | ||
|
||
import copy | ||
import inspect | ||
import pydoc | ||
import re | ||
import sys | ||
import textwrap | ||
from collections import namedtuple | ||
from collections.abc import Callable, Mapping | ||
from functools import cached_property | ||
from warnings import warn | ||
|
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.
Why do we need to vendor numpydoc.docsrape
? I went through the discussion and didn't find where it was discussed.
If our min supported version lacks features that we need, maybe we can just bump the min version ?
- The parameter table in an HTML representation of :class:`base.BaseEstimator` | ||
now has a link to the online documentation for each parameter. |
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 parameter table in an HTML representation of :class:`base.BaseEstimator` | |
now has a link to the online documentation for each parameter. | |
- The parameter table in the HTML representation of all scikit-learn estimators and | |
more generally of estimators inheriting from :class:`base.BaseEstimator` | |
now displays the parameter desciption as a tooltip and has a link to the online | |
documentation for each parameter. |
`table td`is set in notebook with right text-align. | ||
We need to overwrite it. | ||
*/ | ||
.estimator-table table td.param { |
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.
.param-doc-description { | ||
display: none; | ||
position: absolute; | ||
z-index: 9999; | ||
left: 0; | ||
padding: .5ex; | ||
color: var(--sklearn-color-text); | ||
box-shadow: .3em .3em .4em #999; | ||
width: max-content; | ||
text-align: left; | ||
max-height: 10em; | ||
overflow-y: auto; | ||
|
||
/* unfitted */ | ||
background: var(--sklearn-color-unfitted-level-0); | ||
border: thin solid var(--sklearn-color-unfitted-level-3); | ||
} |
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.
def test_generate_link_to_param_doc_special_characters(): | ||
class MockEstimator: | ||
"""Mock class | ||
param with space : {'stay', 'leave'} default='don't know' |
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.
does such a param exists ? I don't see how a parameter could have a space in it's name in Python.
def test_generate_link_to_param_doc_basic(): | ||
class MockEstimator: |
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.
Please add docstring to this test and the following ones. It helps figuring out the purpose of each text.
class MockEstimator: | ||
"""Mock class. | ||
Parameters | ||
---------- | ||
alpha : float | ||
Regularization strength. | ||
beta : int | ||
Some integer parameter. | ||
""" |
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 believe this class could be extracted and used by different tests
Reference Issues/PRs
Adds a column with a link to each parameter docstring in the params table (in the HTML display).
This was discussed while working on the PR that added the table.
"Text fragments" code shared by @ogrisel here :
#30763 (comment)
What does this implement/fix? Explain your changes.
Added a column to the table with the new link
Modified ParamsDict to include the estimator_type. After several tries it was the only way I found at the moment.
Any other comments?
@glemaitre