-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG] Added an example to the sklearn.feature_extraction.image.PatchExtractor #12202
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
sklearn/feature_extraction/image.py
Outdated
-------- | ||
|
||
>>> from sklearn.feature_extraction.image import PatchExtractor | ||
>>> X = np.random.randint(10, size=(2, 2, 2)) |
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.
Maybe use a built-in image instead of random data?
sklearn/feature_extraction/image.py
Outdated
>>> X | ||
array([[[5, 0], | ||
[9, 6]], | ||
|
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 need these new lines.
You can have your example in a file (e.g. example.py
) and pass it to a script like this one with python run_script.py < example.py
and copy/paste the results to the docstring.
sklearn/feature_extraction/image.py
Outdated
>>> pe = PatchExtractor(patch_size=(1024, 2), random_state=1234) | ||
>>> pe.fit(X) | ||
>>> X_transform = pe.transform(X) | ||
>>> X_transform[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.
maybe just show the shape of X_transform? And maybe use a different patch size? this seems strange.
tests are failing. Fit returns self, so you have to add that output. Also there's a pep8 error. |
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.
doctest is still failing. you might benefit from the NORMALIZE_WHITESPACE flag, but I've not looked into the error.
…addition of # doctest: +NORMALIZE_WHITESPACE +DONT_ACCEPT_BLANKLINE +ELLIPSIS for print statements.
…addition of # doctest: +NORMALIZE_WHITESPACE +DONT_ACCEPT_BLANKLINE for print statements.
…DONT_ACCEPT_BLANKLINE (@jnothmam, @reshamas)
#12819 fixed this. |
* Finalizes fix for #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 #12202; white space removal * Closes #12202; white space removal2 * Closes #12202; 3.5 compliance; added >>> in docstring code. * Closes #12202; indentation discrep. * Closes #12202; indentation discrep.2 * Example output formating; @jnotham * Example output formating; forgot flake8 * Closes #12202; Removed excessive indentation in docstring (#wimlds) * Closes #12202; Fixed inconsistent indentation in docstring (#wimlds) * Closes #12202 (#wimlds); intentation, v3.5 compliance * Closes #12202 (#wimlds); Output format issue solved with addition of # doctest: +NORMALIZE_WHITESPACE +DONT_ACCEPT_BLANKLINE +ELLIPSIS for print statements. * Closes #12202 (#wimlds); Output format issue solved with addition of # doctest: +NORMALIZE_WHITESPACE +DONT_ACCEPT_BLANKLINE for print statements. * Closes #12202 (#wimlds); Testing doctest direc.: removed DONT_ACCEPT_BLANKLINE (@jnothmam, @reshamas) * Closes #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.
* 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.
…or class
Reference Issues/PRs
What does this implement/fix? Explain your changes.
I added an example to the sklearn.feature_extraction.image.PatchExtractor (#3846)
Any other comments?