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

Skip to content

Change rstrip() to truncation in test function #8237

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

Merged
merged 1 commit into from
Jan 26, 2017

Conversation

pganssle
Copy link
Contributor

@pganssle pganssle commented Jan 26, 2017

What does this implement/fix? Explain your changes.

In the test_kernel_theta function, s.rstrip('_bounds') is used to strip "_bounds" from the end of a string. This is almost certainly a misuse of the rstrip function, which strips off any number of the characters in the argument from the end, so, for example:

>>> 'some_string_bounds'.rstrip('_bounds')   # This one happens to do what you'd expect
'some_string'
>>> 'noun_unbound_bounds'.rstrip('_bounds')   # All characters from '_bounds' - oh no!
''
>>> 'noun_unbound_bounds'[0:-len('_bounds')] # This is what we expect
'noun_unbound'

Normally I would just do [s if not s.endswith('_bounds') else s[:-len('_bounds')] for s in args], but there's already a filter on args that only takes values that already end with _bounds.

@jnothman
Copy link
Member

Whoops! Thanks!

@jnothman jnothman merged commit 9f6b849 into scikit-learn:master Jan 26, 2017
sergeyf pushed a commit to sergeyf/scikit-learn that referenced this pull request Feb 28, 2017
@Przemo10 Przemo10 mentioned this pull request Mar 17, 2017
Sundrique pushed a commit to Sundrique/scikit-learn that referenced this pull request Jun 14, 2017
NelleV pushed a commit to NelleV/scikit-learn that referenced this pull request Aug 11, 2017
paulha pushed a commit to paulha/scikit-learn that referenced this pull request Aug 19, 2017
maskani-moh pushed a commit to maskani-moh/scikit-learn that referenced this pull request Nov 15, 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.

2 participants