8000 [MRG] Examples use int / int without __future__.division by SebastinSanty · Pull Request #9426 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@SebastinSanty
Copy link
Contributor

Reference Issue

Fixes #9421

What does this implement/fix? Explain your changes.

Include future.division to support int / int

Any other comments?

No.

@amueller amueller changed the title Examples use int / int without __future__.division [MRG + 1] Examples use int / int without __future__.division Jul 20, 2017
@amueller
Copy link
Member

Currently the flake8 test is failing. Can you add the error F404 to the exceptions for examples in build_tools/travis/flake8_diff.sh

@amueller amueller changed the title [MRG + 1] Examples use int / int without __future__.division [MRG] Examples use int / int without __future__.division Jul 20, 2017
input features would be to use univariate feature selection followed by a
traditional (l2-penalised) logistic regression model.
"""
from __future__ import division
Copy link
Member

Choose a reason for hiding this comment

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

this is one way or you just can be explicit with div so 1 / n_classes -> 1. / n_classes

link this no need to hack the pep8 rules :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, true, this seems to be another way to approach this. @jnothman your opinions of using this instead?

Copy link
Member

Choose a reason for hiding this comment

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

I like the __future__ but there are advantages in the other, like not confusing python 2 users who are unaware of the __future__, making copy-paste work. If Alex suggested it, I wouldn't seek a second opinion, either ;)

@SebastinSanty
Copy link
Contributor Author

@amueller tested locally with the exception code and was failing

n_pts = 36
x, y = np.ogrid[0:l, 0:l]
mask_outer = (x - l / 2) ** 2 + (y - l / 2) ** 2 < (l / 2) ** 2
mask_outer = (x - (l * 1.0) / 2) ** 2 + (y - (l * 1.0) / 2) ** 2 \
Copy link
Member

Choose a reason for hiding this comment

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

please use enclosing parenthesis instead of \ to break long lines.

@amueller
Copy link
Member

lgtm :)

@amueller
Copy link
Member

Ugh pep8 complaining about W503 "line break before binary operator". Can we ignore that?

@SebastinSanty
Copy link
Contributor Author

@amueller I updated it :)

n_pts = 36
x, y = np.ogrid[0:l, 0:l]
mask_outer = (x - l / 2) ** 2 + (y - l / 2) ** 2 < (l / 2) ** 2
mask_outer = ((x - (l * 1.0) / 2) ** 2 + (y - (l * 1.0) / 2) ** 2 <
Copy link
Member

Choose a reason for hiding this comment

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

why not just l / 2.0 instead of (l * 1.0) / 2

n_pts = 36
x, y = np.ogrid[0:l, 0:l]
mask_outer = (x - l / 2) ** 2 + (y - l / 2) ** 2 < (l / 2) ** 2
mask_outer = (x - l / 2.0) ** 2 + (y - l / 2.0) ** 2 < (l / 2.0) ** 2
Copy link
Member
@agramfort agramfort Jul 22, 2017

Choose a reason for hiding this comment

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

even better would be:

mask_outer = (x - l. / 2.) ** 2 + (y - l. / 2.) ** 2 < (l. / 2.) ** 2

Copy link
Contributor Author
@SebastinSanty SebastinSanty Jul 22, 2017

Choose a reason for hiding this comment

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

I don't think appending . after variable works. Anyways, I have removed the extra zeroes, as suggested.

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.

Thanks for bearing with our nitpicks

@jnothman jnothman merged commit e33e84d into scikit-learn:master Jul 23, 2017
jnothman pushed a commit to jnothman/scikit-learn that referenced this pull request Aug 6, 2017
dmohns pushed a commit to dmohns/scikit-learn that referenced this pull request Aug 7, 2017
dmohns pushed a commit to dmohns/scikit-learn that referenced this pull request Aug 7, 2017
paulha pushed a commit to paulha/scikit-learn that referenced this pull request Aug 19, 2017
AishwaryaRK pushed a commit to AishwaryaRK/scikit-learn that referenced this pull request Aug 29, 2017
maskani-moh pushed a commit to maskani-moh/scikit-learn that referenced this pull request Nov 15, 2017
jwjohnson314 pushed a commit to jwjohnson314/scikit-learn that referenced this pull request Dec 18, 2017
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.

Examples use int / int without __future__.division

4 participants

0