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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions gensim/models/lsimodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.


self.docs_processed = 0
self.projection = Projection(self.num_terms, self.num_topics, power_iters=self.power_iters, extra_dims=self.extra_samples)
Expand Down