[minhashing] Protect minhashing against shape < 1, see #182033
authorVincent Michel <vincent.michel@logilab.fr>
Tue, 15 Oct 2013 08:41:20 +0000
changeset 306 cf1e78baf803
parent 305 afe25ae5facf
child 307 31a13077a293
[minhashing] Protect minhashing against shape < 1, see #182033
minhashing.py
--- a/minhashing.py	Tue Oct 08 13:19:27 2013 +0000
+++ b/minhashing.py	Tue Oct 15 08:41:20 2013 +0000
@@ -31,8 +31,9 @@
         h:x -> ax + b mod R
 
     """
-    a = randint(1, zr - 1)
-    b = randint(1, zr - 1)
+    bound = max(zr - 1, 1)
+    a = randint(1, bound)
+    b = randint(1, bound)
 
     def hashfunc(x):
         return ((a*x + b)%zr)