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

mutable args changed None to empty tuple #1572

Closed
wants to merge 1 commit into from

Conversation

zsef123
Copy link
Contributor

@zsef123 zsef123 commented Sep 6, 2017

@gojomo
Issue(Closed) #1561
PR (Merged) #1562

In PR #1562, I changed empty list in default arguments to None and add check None
e.g)

def foo( arg=None):
    if arg is None:
        arg = []

But I requested under the comment

gojomo 5 hours ago Member
Making these defaults empty tuples – () – could enforce the immutability, and eliminate the later None-check/assignments.

So I change None to empty tuple () excepts graph.py.

In graph.py, can't apply these change.

@zsef123
Copy link
Contributor Author

zsef123 commented Sep 6, 2017

======================================================================
ERROR: testMostSimilarCosmul (gensim.test.test_fasttext_wrapper.TestFastText)
Test most_similar_cosmul for in-vocab and out-of-vocab words
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/RaRe-Technologies/gensim/gensim/test/test_fasttext_wrapper.py", line 272, in testMostSimilarCosmul
    self.assertEqual(len(self.test_model.most_similar_cosmul(positive=['the', 'and'], topn=5)), 5)
  File "/home/travis/build/RaRe-Technologies/gensim/gensim/models/word2vec.py", line 1250, in most_similar_cosmul
    return self.wv.most_similar_cosmul(positive, negative, topn)
  File "/home/travis/build/RaRe-Technologies/gensim/gensim/models/keyedvectors.py", line 476, in most_similar_cosmul
    all_words = set([self.vocab[word].index for word in positive + negative
TypeError: can only concatenate list (not "tuple") to list
======================================================================
ERROR: test_cosmul (gensim.test.test_word2vec.TestWord2VecModel)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/RaRe-Technologies/gensim/gensim/test/test_word2vec.py", line 465, in test_cosmul
    sims = model.most_similar_cosmul('graph', topn=10)
  File "/home/travis/build/RaRe-Technologies/gensim/gensim/models/word2vec.py", line 1250, in most_similar_cosmul
    return self.wv.most_similar_cosmul(positive, negative, topn)
  File "/home/travis/build/RaRe-Technologies/gensim/gensim/models/keyedvectors.py", line 476, in most_similar_cosmul
    all_words = set([self.vocab[word].index for word in positive + negative
TypeError: can only concatenate list (not "tuple") to list
----------------------------------------------------------------------

test failed

@zsef123 zsef123 closed this Sep 6, 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.

1 participant