Skip to content

Commit

Permalink
allow lists as sparse document elements (was: only 2-tuples)
Browse files Browse the repository at this point in the history
* `doc = [[0, 1.2], [1, 0.4]]` is now ok, in addition to `[(0, 1.2), (1, 0.4)]`
  • Loading branch information
piskvorky committed Nov 11, 2012
1 parent fe10108 commit 4d09ceb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gensim/matutils.py
Expand Up @@ -281,7 +281,7 @@ def unitvec(vec):
except:
return vec

if isinstance(first, tuple): # gensim sparse format?
if isinstance(first, (tuple, list)) and len(first) == 2: # gensim sparse format?
length = 1.0 * math.sqrt(sum(val**2 for _, val in vec))
assert length > 0.0, "sparse documents must not contain any explicit zero entries"
if length != 1.0:
Expand Down

0 comments on commit 4d09ceb

Please sign in to comment.