Skip to content

Commit

Permalink
Add warning when string is used as argument to infer_vector() (#2347)
Browse files Browse the repository at this point in the history
* correct name of 'sentences' argument to 'documents in docstrings; minor docstring clarifications over which I stumbled

* add warning when string is used as argument to infer_vector()

* change warning about single string to exception

* change ValueError to TypeError and make error message more explicit
  • Loading branch information
tobycheese authored and piskvorky committed Jan 23, 2019
1 parent 95e222a commit 0cc0994
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gensim/models/doc2vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,9 @@ def infer_vector(self, doc_words, alpha=None, min_alpha=None, epochs=None, steps
The inferred paragraph vector for the new document.
"""
if isinstance(doc_words, string_types):
raise TypeError("Parameter doc_words of infer_vector() must be a list of strings (not a single string).")

alpha = alpha or self.alpha
min_alpha = min_alpha or self.min_alpha
epochs = epochs or steps or self.epochs
Expand Down

0 comments on commit 0cc0994

Please sign in to comment.