Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit 4d09cebf08925db8d62be1ce760aed7e7609b7bf 1 parent fe10108
@piskvorky authored
Showing with 1 addition and 1 deletion.
  1. +1 −1  gensim/matutils.py
View
2  gensim/matutils.py
@@ -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:
Please sign in to comment.
Something went wrong with that request. Please try again.