Permalink
Browse files

allow lists as sparse document elements (was: only 2-tuples)

* `doc = [[0, 1.2], [1, 0.4]]` is now ok, in addition to `[(0, 1.2), (1, 0.4)]`
  • Loading branch information...
1 parent fe10108 commit 4d09cebf08925db8d62be1ce760aed7e7609b7bf @piskvorky piskvorky committed Nov 11, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 gensim/matutils.py
View
@@ -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:

0 comments on commit 4d09ceb

Please sign in to comment.