-
-
Notifications
You must be signed in to change notification settings - Fork 26k
DOC Use numpydoc_use_plots
to embed figures for plotting APIs in the documentation
#20705
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
Conversation
Signed-off-by: harupy <[email protected]>
Signed-off-by: harupy <[email protected]>
As commented here: #18331 (comment), this PR requires updating the mininum matplotlib version to 3.1.0 (released on May 19, 2019) from 2.2.2 (released on Mar 18, 2018): scikit-learn/sklearn/_min_dependencies.py Line 28 in 4b0d291
|
It looks like something is wrong with the det-curve example: |
We need to use a real dataset then :) Build a curve with 3 samples will not really work :) |
You will need also to update the README regarding the matplotlib version for the test to pass. |
Agree, I filed #20709.
Thanks, updated |
doc/conf.py
Outdated
|
||
# Options for the `::plot` directive: | ||
# https://matplotlib.org/stable/api/sphinxext_plot_directive_api.html | ||
plot_formats = ["png"] |
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.
plot_formats
defaults to ['png', 'hires.png', 'pdf']
, but just creating a png should be enough:
a8983a7
to
3477bb3
Compare
@glemaitre Addressed your comments. Could you take another look? |
I think that we could make the change for the DetCurve in this PR as well to be sure that once merge, all the plotting will look okay. Could you trigger a full documentation build by including It will allow to check that everything is fine. |
d6aae2a
to
2499fbb
Compare
@glemaitre Got it, pushed a few commits to address your comments. |
Now the plot for the I think increasing |
Yes, a bit more samples could be good then :) |
Nice :). It is enough for me. |
yeah, it's enough for an example. |
doc/conf.py
Outdated
] | ||
|
||
# this is needed for some reason... | ||
# see https://github.com/numpy/numpydoc/issues/69 | ||
numpydoc_class_members_toctree = False | ||
|
||
# Produce `plot::` directives for examples that contain `import matplotlib` or |
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.
Bumping the matplotlib version for nicer plotting in docstrings does not look like a strong enough reason. A compromise would be to only generate the plots for newer version of matplotlib:
# support for `plot::` directives in sphinx 3.2 require matplotlib 3.1.0
if parse_version(mpl.__version__) > parse_version("3.1.0"):
extensions.append("matplotlib.sphinxext.plot_directive")
This will still generate the plots for the hosted docs.
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.
It is fine with me.
This said, I am not sure that I would encourage anymore to not have the latest major revision of a Python package -> pandas 1.x, matplotlib 3.x. But for sure this is not the debate here :)
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.
Looks good!
I still think that we should generate the full documentation with a message commit containing |
28b48d2
to
27f9f74
Compare
08d146f
to
4a57119
Compare
@glemaitre @thomasjpfan Could you take another look? |
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
@@ -49,6 +50,21 @@ | |||
"sphinxext.opengraph", | |||
] | |||
|
|||
# Support for `plot::` directives in sphinx 3.2 requires matplotlib 3.1.0 or newer | |||
if parse(mpl.__version__) >= parse("3.1.0"): |
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.
When we finally update our matplotlib min version, we can remove this version parsing.
numpydoc_use_plots
to embed figures for plotting APIs in the documentationnumpydoc_use_plots
to embed figures for plotting APIs in the documentation
We need an additional Everything else seems fine. |
@glemaitre Addressed your comments :) |
sklearn/metrics/_plot/det_curve.py
Outdated
>>> X_train, X_test, y_train, y_test = train_test_split( | ||
... X, y, test_size=0.4, random_state=0) | ||
>>> clf = SVC(random_state=0).fit(X_train, y_train) | ||
>>> plot_det_curve(clf, X_test, y_test) |
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 we will raise a deprecation warning. It might be best to keep the skip then.
Co-authored-by: Guillaume Lemaitre <[email protected]>
@glemaitre Could you take another look? |
@glemaitre @thomasjpfan gentle ping. |
I have already approved this PR. I think this is a big enough change to require another review to approve before merging. |
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 checked another time the output and LGTM
Thanks @harupy |
…e documentation (scikit-learn#20705) Co-authored-by: Guillaume Lemaitre <[email protected]>
Signed-off-by: harupy [email protected]
Reference Issues/PRs
sklearn.metrics.DetCurveDisplay.__init__
plots nothing #20709Example:
https://147424-843222-gh.circle-artifacts.com/0/doc/modules/generated/sklearn.metrics.ConfusionMatrixDisplay.html?highlight=from_predictions#sklearn.metrics.ConfusionMatrixDisplay.from_predictions
What does this implement/fix? Explain your changes.
Any other comments?