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

Skip to content

0.8.x (to be cp to master as well) PLS -- use string comparisons (instead of identity checking) and few spell fixes #164

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 2 commits into from
May 12, 2011

Conversation

yarikoptic
Copy link
Member

real-life example of strings not always (I am not even talking about possible unicode here) being singletones, thus inappropriate for 'is' whenever '==' is intended:

(Pdb) self.algorithm is "nipals"
False
*(Pdb) self.algorithm == "nipals"
True
*(Pdb) print self.algorithm
nipals
*(Pdb) print repr(self.algorithm)
'nipals'
*(Pdb) print self.algorithm.__class__
<type 'str'>

(Pdb) self.algorithm is "nipals"
False
*(Pdb) self.algorithm == "nipals"
True
*(Pdb) print self.algorithm
nipals
*(Pdb) print repr(self.algorithm)
'nipals'
*(Pdb) print self.algorithm.__class__
<type 'str'>
@GaelVaroquaux
Copy link
Member

Yup, indeed. 'is' shouldn't be used for checking for equality. Thank you!

GaelVaroquaux added a commit that referenced this pull request May 12, 2011
0.8.x (to be cp to master as well) PLS -- use string comparisons (instead of identity checking) and few spell fixes
@GaelVaroquaux GaelVaroquaux merged commit 67ff4ef into scikit-learn:0.8.X May 12, 2011
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