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

Fixes bug in LsiModel that occurs when id2word is a Python 3 dictionary. #1103

Merged
merged 3 commits into from
Jan 24, 2017

Conversation

cvangysel
Copy link
Contributor

The error message "you cannot concatenate dictionary keys with a list" is thrown when passing dictionary id2word to gensim.models.lsimodel.LsiModel in Python 3.

@@ -298,7 +298,8 @@ def __init__(self, corpus=None, num_topics=200, id2word=None, chunksize=20000,
self.id2word = utils.dict_from_corpus(corpus)
self.num_terms = len(self.id2word)
else:
self.num_terms = 1 + max([-1] + self.id2word.keys())
self.num_terms = (
1 + max(self.id2word.keys()) if self.id2word else -1)
Copy link
Owner

Choose a reason for hiding this comment

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

Looks good but keep the expression on one line please.

@cvangysel
Copy link
Contributor Author

Done.

@@ -298,8 +298,7 @@ def __init__(self, corpus=None, num_topics=200, id2word=None, chunksize=20000,
self.id2word = utils.dict_from_corpus(corpus)
self.num_terms = len(self.id2word)
else:
self.num_terms = (
1 + max(self.id2word.keys()) if self.id2word else -1)
self.num_terms = 1 + max(self.id2word.keys()) if self.id2word else -1
Copy link
Owner

@piskvorky piskvorky Jan 23, 2017

Choose a reason for hiding this comment

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

Please put brackets around the ternary expression, its reading is a little ambiguous / confusing now (1 + not included).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@piskvorky
Copy link
Owner

Thanks @cvangysel !

CC @tmylk LGTM.

@tmylk tmylk merged commit e411433 into piskvorky:develop Jan 24, 2017
@tmylk
Copy link
Contributor

tmylk commented Jan 24, 2017

Thanks for the PR!

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.

3 participants