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`
Parameters
----------
......@@ -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
random.seed(string_seed)
return "".join(random.choice(letters) for i in range(word_length))
return str(sum([ord(i) for i in (key)]) % bucket_size)
Markdown is supported
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