Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[MRG] Fixed warnings mentioned in #11554 #11670

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

Closed
wants to merge 7 commits into from

Conversation

prathusha94
Copy link

Reference Issues/PRs

Fixes #11554

What does this implement/fix? Explain your changes.

I have changed this line rescaled_coins = rescale(smoothened_coins, 0.2, mode="reflect") in both the coin-segmentation examples to rescaled_coins = rescale(smoothened_coins, 0.2, mode="reflect",multichannel=False,anti_aliasing=False)

The coin segmentation examples issued two warnings if:
a) "multichannel" argument is not mentioned (i.e None) in the rescale(). This argument is set to "True" only for 3D or 2D colour inputs. Since the coins image used in the example is a grayscale image I have set the argument to False.

b)"anti_aliasing" argument is not mentioned (i.e None) in the rescale(). The argument should be "True" to apply a Gaussian filter to smooth the image prior to down-scaling. Since this line smoothened_coins = gaussian_filter(orig_coins, sigma=2) before rescale() is already applying the filter, I have set the argument to False

Any other comments?

This is my first ever Pull request and I have tried to follow all the guidelines. If I have still messed up anything, I would really appreciate any guidance.

@rasbt
Copy link
Contributor

rasbt commented Jul 25, 2018

Hi there, just saw your Q via the mailing list. So, the Travis issue is due to pep8 violations (a Python style guide, more info here: https://www.python.org/dev/peps/pep-0008/)

E.g., if you look at the logs in the travis report, you see sth like

> examples/cluster/plot_coin_ward_segmentation.py:39:63: E231 missing whitespace after ','
rescaled_coins = rescale(smoothened_coins, 0.2, mode="reflect",multichannel=False,anti_aliasing=False)
                                                              ^
examples/cluster/plot_coin_ward_segmentation.py:39:80: E501 line too long (102 > 79 characters)
rescaled_coins = rescale(smoothened_coins, 0.2, mode="reflect",multichannel=False,anti_aliasing=False)
                                                                               ^
examples/cluster/plot_coin_ward_segmentation.py:39:82: E231 missing whitespace after ','
rescaled_coins = rescale(smoothened_coins, 0.2, mode="reflect",multichannel=False,anti_aliasing=False)
                                                                                ^

That essentially indicates you are missing a white space between the function arguments. I.e., instead of

mode="reflect",multichannel=False,anti_aliasing=False

write

mode="reflect", multichannel=False, anti_aliasing=False

I recommend using a pep8 or flake8 plugin for your text editor that highlights these issues. Or you could run pep8 or flake8 tool to before resubmitting the code to make sure you catch all of these. Flake8 is basically an advanced version of the pep8 tool (= a tool for Python that checks for PEP8 style), where it also checks for unused variable names, unused imports, etc.

After installing flake8 (https://pypi.org/project/flake8/; e.g., via pip install flake8), you should be able to call it as a command line tool, e.g., flake8 sklearn/.../your-code.py

@@ -2,7 +2,7 @@
================================================
Segmenting the picture of greek coins in regions
================================================

p
Copy link
Contributor

Choose a reason for hiding this comment

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

this is probably a typo, right?

@@ -36,7 +36,7 @@
# Applying a Gaussian filter for smoothing prior to down-scaling
# reduces aliasing artifacts.
smoothened_coins = gaussian_filter(orig_coins, sigma=2)
rescaled_coins = rescale(smoothened_coins, 0.2, mode="reflect")
rescaled_coins = rescale(smoothened_coins, 0.2, mode="reflect",multichannel=False,anti_aliasing=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

Add whitespace after each comment. Then split the line so it doesn't exceed 80 char

@prathusha94
Copy link
Author

Thank you very much @rasbt ! That makes so much sense now !

@rasbt
Copy link
Contributor

rasbt commented Jul 25, 2018

No problem. The reason for the other error (the unrecognized multichannel arg in skimage's rescale) is prob because scikit-image used in the CircleCI build is simply too old. This would need to be updated here:

- SCIKIT_IMAGE_VERSION: 0.9.3

but should probably be discussed with the core devs

@prathusha94
Copy link
Author

@amueller @jnothman is it possible to update the version of scikit-image used in CircleCi ?

@jnothman
Copy link
Member

jnothman commented Jul 26, 2018 via email

@prathusha94
Copy link
Author

sure. check build_tools/circle
@jnothman This is the only piece of code I see in build_tools/circle that is related to scikit-image version.
conda create -n $CONDA_ENV_NAME --yes --quiet python="${PYTHON_VERSION:-*}" \ numpy="${NUMPY_VERSION:-*}" scipy="${SCIPY_VERSION:-*}" cython \ pytest coverage matplotlib="${MATPLOTLIB_VERSION:-*}" sphinx=1.6.2 pillow \ scikit-image="${SCIKIT_IMAGE_VERSION:-*}" pandas="${PANDAS_VERSION:-*}"

And I think the value for ${SCIKIT_IMAGE_VERSION:-*} is coming from the file .circleci/congif.yml (SCIKIT_IMAGE_VERSION: 0.9.3 - line 49)
Since this is supposed to be a hidden file , I'm not sure if I have the permission to make any changes.

@jnothman
Copy link
Member

jnothman commented Jul 29, 2018 via email

@jnothman
Copy link
Member

jnothman commented Jul 29, 2018 via email

Copy link
Member

@jnothman jnothman left a comment

Choose a reason for hiding this comment

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

I actually don't think we can nicely resolve this yet

@lesteve
Copy link
Member

lesteve commented Jul 31, 2018

I actually don't think we can nicely resolve this yet

Agreed. IIRC our dependencies versions are based on what the packages version is in Ubuntu 14.04 hence scikit-image 0.9.3.

More generally, getting rid of deprecation warnings and keeping compatibility with old versions are going to be at odds with each other. You could potentially complicate the example code (e.g. by adding an if clause based on the version of scikit-image in this case) but complicating an example without a very good reason is something we try to avoid.

@prathusha94
Copy link
Author

prathusha94 commented Jul 31, 2018 via email

@rth
Copy link
Member

rth commented Jul 12, 2019

This was resolved in #12654 . Closing. Thanks for contributing.

@rth rth closed this Jul 12, 2019
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.

deprecation warnings in coin examples
5 participants