Commit 607bee73 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Removed the randomness from hash_string

parent 99fa97c0
......@@ -2,8 +2,6 @@ import pickle
import nose
import numpy as np
import random
import string
def is_picklable(obj):
......@@ -80,9 +78,10 @@ def isinstance_nested(instance, attribute, isinstance_of):
return isinstance_nested(getattr(instance, attribute), attribute, isinstance_of)
def hash_string(key, bucket_size=1000, word_length=8):
def hash_string(key, bucket_size=1000):
Generates a hash code given a string.
The have is given by the `sum(ord([string])) mod bucket_size`
......@@ -93,18 +92,5 @@ def hash_string(key, bucket_size=1000, word_length=8):
bucket_size: int
Size of the hash table.
word_lenth: str
Size of the output string
letters = string.ascii_lowercase
# Getting an integer value from the key
# and mod `n_slots` to have values between 0 and 1000
string_seed = sum([ord(i) for i in (key)]) % bucket_size
# Defining the seed so we have predictable values
return "".join(random.choice(letters) for i in range(word_length))
return str(sum([ord(i) for i in (key)]) % bucket_size)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment