-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
DOC Adds an example to PatchExtractor #12819
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
Thanks. Finally, I think the example should be added to the class docstring, not the transform method docstring, no ? |
@CatChenal Thanks so much for assisting with this list of PRs!
|
I agree that the example should be at the Should I do so? Also note that the example under the |
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 pointed only 2 issues but they are at multiple locations.
sklearn/feature_extraction/image.py
Outdated
>>> patches[8] | ||
array([[10, 11], | ||
[14, 15]]) | ||
from sklearn.datasets import load_sample_images |
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.
You should use a 4 spaces indent. It looks like a tab instead. You should also prepend >>> before a command as in the previous example.
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 ran Flake8 on sklearn/feature_extraction/image.py: there was no output, hence I took that to mean that there was no style issue.
I'll fix that momentarily.
sklearn/feature_extraction/image.py
Outdated
|
||
# Use the array data from the first image in this dataset: | ||
one_image = load_sample_images().images[0] | ||
print(f'Image shape: {one_image.shape}') |
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.
This string formatting is only available in python 3.6. We are still supporting python 3.5. Use normal string with format 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.
OK.
@CatChenal to update the description, at the very top, on the upper right are "..." |
The scope of the original issue was to add examples to the class docstrings, I guess we can keep it that way and avoid including examples to functions' docstrings, at least for now. |
Thank you all and sorry about neglecting it. |
sklearn/feature_extraction/image.py
Outdated
>>> one_image = load_sample_images().images[0] | ||
|
||
>>> print('Image shape: {}'.format(one_image.shape)) | ||
|
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 output should be immediately after the statement that produced it
@CatChenal |
Happy New Year to you too, @reshamas. Could please you confirm my understanding of the failed check? |
@CatChenal |
test failing, you also need to merge master into your branch to fix the conflicts. |
I don't know what to do now: "Already up to date." is the result of |
You need to have and upstream set up in your local clone and merge from that. There's a bit of documentation with some good keywords here: https://scikit-learn.org/dev/developers/contributing.html#how-to-contribute As for this PR, it's easier if you get the output from a script such as this one: https://gist.github.com/adrinjalali/eca43556ca1620c72d91d8326ca59587 You can also check out some of the related PRs linked in this issue: #3846 |
This worked:
Thank you @jnothman @adrinjalali @reshamas |
…addition of # doctest: +NORMALIZE_WHITESPACE +DONT_ACCEPT_BLANKLINE +ELLIPSIS for print statements.
…addition of # doctest: +NORMALIZE_WHITESPACE +DONT_ACCEPT_BLANKLINE for print statements.
sklearn/feature_extraction/image.py
Outdated
>>> | ||
>>> # Here are just two of these patches: | ||
>>> print(patches[1]) # doctest: +NORMALIZE_WHITESPACE \ | ||
+DONT_ACCEPT_BLANKLINE |
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 think you should need DONT_ACCEPT_BLANKLINE
. Are you sure it's necessary?
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.
@CatChenal can you give it a try without the DONT_ACCEPT_BLANKLINE
option?
…DONT_ACCEPT_BLANKLINE (@jnothmam, @reshamas)
At last: LGTM! |
sklearn/feature_extraction/image.py
Outdated
[ 4, 5, 6, 7], | ||
[ 8, 9, 10, 11], | ||
[12, 13, 14, 15]]) | ||
>>> |
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 remove these empty lines
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.
otherwise LGTM! Thanks @CatChenal
@CatChenal It looks like there is one last request from @adrinjalali to remove some empty lines. Hopefully once that is completed by you, the PR can be merged in. |
@reshamas My last push took care of it. |
@CatChenal I still see the empty lines beginning with |
@reshamas You were right! My bad! |
I don't understand the new failure on CI: relates to #13067?? |
Thanks @CatChenal ! |
Thanks @CatChenal 👏 - I've updated the Sprint Impact Report with your merge. Thanks @adrinjalali and @jnothman. |
Thank you all @adrinjalali, @jnothman, and @reshamas. |
* Finalizes fix for scikit-learn#12202 from abandonned PR by @parul-l * Completes 12202 fix abandoned by @parul-l * Completes 12202 fix abandoned by @parul-l * Extends 12202 fix over feature_extraction/image.py * Closes scikit-learn#12202; white space removal * Closes scikit-learn#12202; white space removal2 * Closes scikit-learn#12202; 3.5 compliance; added >>> in docstring code. * Closes scikit-learn#12202; indentation discrep. * Closes scikit-learn#12202; indentation discrep.2 * Example output formating; @jnotham * Example output formating; forgot flake8 * Closes scikit-learn#12202; Removed excessive indentation in docstring (#wimlds) * Closes scikit-learn#12202; Fixed inconsistent indentation in docstring (#wimlds) * Closes scikit-learn#12202 (#wimlds); intentation, v3.5 compliance * Closes scikit-learn#12202 (#wimlds); Output format issue solved with addition of # doctest: +NORMALIZE_WHITESPACE +DONT_ACCEPT_BLANKLINE +ELLIPSIS for print statements. * Closes scikit-learn#12202 (#wimlds); Output format issue solved with addition of # doctest: +NORMALIZE_WHITESPACE +DONT_ACCEPT_BLANKLINE for print statements. * Closes scikit-learn#12202 (#wimlds); Testing doctest direc.: removed DONT_ACCEPT_BLANKLINE (@jnothmam, @reshamas) * Closes scikit-learn#12202 (#wimlds); Removed blank lines in doctest example.
* Finalizes fix for scikit-learn#12202 from abandonned PR by @parul-l * Completes 12202 fix abandoned by @parul-l * Completes 12202 fix abandoned by @parul-l * Extends 12202 fix over feature_extraction/image.py * Closes scikit-learn#12202; white space removal * Closes scikit-learn#12202; white space removal2 * Closes scikit-learn#12202; 3.5 compliance; added >>> in docstring code. * Closes scikit-learn#12202; indentation discrep. * Closes scikit-learn#12202; indentation discrep.2 * Example output formating; @jnotham * Example output formating; forgot flake8 * Closes scikit-learn#12202; Removed excessive indentation in docstring (#wimlds) * Closes scikit-learn#12202; Fixed inconsistent indentation in docstring (#wimlds) * Closes scikit-learn#12202 (#wimlds); intentation, v3.5 compliance * Closes scikit-learn#12202 (#wimlds); Output format issue solved with addition of # doctest: +NORMALIZE_WHITESPACE +DONT_ACCEPT_BLANKLINE +ELLIPSIS for print statements. * Closes scikit-learn#12202 (#wimlds); Output format issue solved with addition of # doctest: +NORMALIZE_WHITESPACE +DONT_ACCEPT_BLANKLINE for print statements. * Closes scikit-learn#12202 (#wimlds); Testing doctest direc.: removed DONT_ACCEPT_BLANKLINE (@jnothmam, @reshamas) * Closes scikit-learn#12202 (#wimlds); Removed blank lines in doctest example.
* Finalizes fix for scikit-learn#12202 from abandonned PR by @parul-l * Completes 12202 fix abandoned by @parul-l * Completes 12202 fix abandoned by @parul-l * Extends 12202 fix over feature_extraction/image.py * Closes scikit-learn#12202; white space removal * Closes scikit-learn#12202; white space removal2 * Closes scikit-learn#12202; 3.5 compliance; added >>> in docstring code. * Closes scikit-learn#12202; indentation discrep. * Closes scikit-learn#12202; indentation discrep.2 * Example output formating; @jnotham * Example output formating; forgot flake8 * Closes scikit-learn#12202; Removed excessive indentation in docstring (#wimlds) * Closes scikit-learn#12202; Fixed inconsistent indentation in docstring (#wimlds) * Closes scikit-learn#12202 (#wimlds); intentation, v3.5 compliance * Closes scikit-learn#12202 (#wimlds); Output format issue solved with addition of # doctest: +NORMALIZE_WHITESPACE +DONT_ACCEPT_BLANKLINE +ELLIPSIS for print statements. * Closes scikit-learn#12202 (#wimlds); Output format issue solved with addition of # doctest: +NORMALIZE_WHITESPACE +DONT_ACCEPT_BLANKLINE for print statements. * Closes scikit-learn#12202 (#wimlds); Testing doctest direc.: removed DONT_ACCEPT_BLANKLINE (@jnothmam, @reshamas) * Closes scikit-learn#12202 (#wimlds); Removed blank lines in doctest example.
This reverts commit 9bcf9c9.
This reverts commit 9bcf9c9.
* Finalizes fix for scikit-learn#12202 from abandonned PR by @parul-l * Completes 12202 fix abandoned by @parul-l * Completes 12202 fix abandoned by @parul-l * Extends 12202 fix over feature_extraction/image.py * Closes scikit-learn#12202; white space removal * Closes scikit-learn#12202; white space removal2 * Closes scikit-learn#12202; 3.5 compliance; added >>> in docstring code. * Closes scikit-learn#12202; indentation discrep. * Closes scikit-learn#12202; indentation discrep.2 * Example output formating; @jnotham * Example output formating; forgot flake8 * Closes scikit-learn#12202; Removed excessive indentation in docstring (#wimlds) * Closes scikit-learn#12202; Fixed inconsistent indentation in docstring (#wimlds) * Closes scikit-learn#12202 (#wimlds); intentation, v3.5 compliance * Closes scikit-learn#12202 (#wimlds); Output format issue solved with addition of # doctest: +NORMALIZE_WHITESPACE +DONT_ACCEPT_BLANKLINE +ELLIPSIS for print statements. * Closes scikit-learn#12202 (#wimlds); Output format issue solved with addition of # doctest: +NORMALIZE_WHITESPACE +DONT_ACCEPT_BLANKLINE for print statements. * Closes scikit-learn#12202 (#wimlds); Testing doctest direc.: removed DONT_ACCEPT_BLANKLINE (@jnothmam, @reshamas) * Closes scikit-learn#12202 (#wimlds); Removed blank lines in doctest example.
What does this implement/fix?
Completes #12202 fix abandoned by @parul-l.
Modifications made as per @amueller and @adrinjalali:
Replaced random data with an image from sklearn image dataset;
Reformated the output.
Any other comments?
This completed fix results from Reshama Shaikh's push to close all PRs opened during WiMLDS's scikit-learn sprint in Sep. 2018.
Yes, Reshama is herding cats!
cc: @reshamas