Skip to content
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

DOC Adds an example to PatchExtractor #12819

Merged
merged 19 commits into from Jan 31, 2019

Conversation

CatChenal
Copy link
Contributor

@CatChenal CatChenal commented Dec 18, 2018

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

@jeremiedbb
Copy link
Member

Thanks.
Please give a more informative title to your PR
Also please add Fix #12202 to the description of you PR so that the issue will be closed when you PR is merged.

Finally, I think the example should be added to the class docstring, not the transform method docstring, no ?

@reshamas
Copy link
Member

@CatChenal Thanks so much for assisting with this list of PRs!

  1. Possible title for PR: "example added to the feature_extraction.image.PatchExtractor"

  2. Here is a reference for Closing Issues Using Keywords: "This closes [MRG] Added an example to the sklearn.feature_extraction.image.PatchExtractor #12202 and references Add examples to class docs #3846"

@CatChenal
Copy link
Contributor Author

Thanks.
Please give a more informative title to your PR
Also please add Fix #12202 to the description of you PR so that the issue will be closed when you PR is merged.

Finally, I think the example should be added to the class docstring, not the transform method docstring, no ?

I agree that the example should be at the PatchExtractor class level, but this issue was not addressed by the original PR's two commenters, @amueller or @adrinjalali, therefore I did not move the example.

Should I do so?

Also note that the example under the extract_patches_2d method (line 339) in feature_extaction/image submodule suffers from the same objection by @amueller in #12202, namely the use of synthetic array data while there are small built-in images at the ready.
Would that constitute a new issue, e.g. "Data source in examples for small image processing: use built-in images, not random arrays", or should I perform the move and the image source modification in the same pull?

Copy link
Member

@glemaitre glemaitre left a 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.

>>> patches[8]
array([[10, 11],
[14, 15]])
from sklearn.datasets import load_sample_images
Copy link
Member

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.

Copy link
Contributor Author

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.


# 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}')
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

@reshamas
Copy link
Member

@CatChenal to update the description, at the very top, on the upper right are "..."
Click on those 3 dots and there will an option to edit the text of the description of the PR.

@CatChenal CatChenal changed the title Fixes #12202 Closes #12202 Dec 18, 2018
@adrinjalali adrinjalali changed the title Closes #12202 Adds an example to PatchExtractor Dec 18, 2018
@adrinjalali
Copy link
Member

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.

@parul-l
Copy link

parul-l commented Dec 19, 2018

Thank you all and sorry about neglecting it.

>>> one_image = load_sample_images().images[0]

>>> print('Image shape: {}'.format(one_image.shape))

Copy link
Member

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

@reshamas
Copy link
Member

reshamas commented Jan 5, 2019

@CatChenal
Happy New Year!
Will you be able to continue work on this PR?

@CatChenal
Copy link
Contributor Author

Happy New Year to you too, @reshamas.
Thanks for the reminder.

Could please you confirm my understanding of the failed check?
As per the 'Resolve conflict' page, it is an indentation issue.
Thanks.

@reshamas
Copy link
Member

reshamas commented Jan 5, 2019

@CatChenal
It looks like it. Reminder to update the description of the PR as well. Thanks.
Give it a try, and let's keep our fingers crossed that all checks pass.

@adrinjalali
Copy link
Member

test failing, you also need to merge master into your branch to fix the conflicts.

@CatChenal
Copy link
Contributor Author

I don't know what to do now: "Already up to date." is the result of git merge master.

@adrinjalali
Copy link
Member

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

@CatChenal
Copy link
Contributor Author

This worked:

    >>> print(patches[1]) # doctest: +NORMALIZE_WHITESPACE +DONT_ACCEPT_BLANKLINE
    [[[174 201 231]
      [174 201 231]]
     [[173 200 230]
      [173 200 230]]]

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.
>>>
>>> # Here are just two of these patches:
>>> print(patches[1]) # doctest: +NORMALIZE_WHITESPACE \
+DONT_ACCEPT_BLANKLINE
Copy link
Member

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?

Copy link
Member

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?

@CatChenal
Copy link
Contributor Author

At last: LGTM!

@jnothman jnothman changed the title Adds an example to PatchExtractor DOC Adds an example to PatchExtractor Jan 27, 2019
[ 4, 5, 6, 7],
[ 8, 9, 10, 11],
[12, 13, 14, 15]])
>>>
Copy link
Member

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

Copy link
Member

@adrinjalali adrinjalali left a 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

@reshamas
Copy link
Member

@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.

@CatChenal
Copy link
Contributor Author

@reshamas My last push took care of it.

@reshamas
Copy link
Member

@CatChenal I still see the empty lines beginning with >>>
notice the example in here does not have any blank lines: https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/feature_extraction/image.py

@CatChenal
Copy link
Contributor Author

@reshamas You were right! My bad!

@CatChenal
Copy link
Contributor Author

I don't understand the new failure on CI: relates to #13067??

@adrinjalali
Copy link
Member

Thanks @CatChenal !

@reshamas
Copy link
Member

Thanks @CatChenal 👏 - I've updated the Sprint Impact Report with your merge.

Thanks @adrinjalali and @jnothman.

@CatChenal
Copy link
Contributor Author

Thank you all @adrinjalali, @jnothman, and @reshamas.
My future contributions will be better managed from the lessons learned here.

@CatChenal CatChenal deleted the myfeature branch January 31, 2019 14:42
thomasjpfan pushed a commit to thomasjpfan/scikit-learn that referenced this pull request Feb 6, 2019
* 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.
thomasjpfan pushed a commit to thomasjpfan/scikit-learn that referenced this pull request Feb 7, 2019
* 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.
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
* 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.
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
koenvandevelde pushed a commit to koenvandevelde/scikit-learn that referenced this pull request Jul 12, 2019
* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants