Vermont Virginia Washington WestVirginia Wisconsin Wyoming'''.split() bf1 = BloomFilter(ideal_num_elements_n=100000, error_rate_p=0.001) for state in states: bf1.add(state) json_bf = bf1.toJSON() print "##################" print json_bf print "##################" len_json = len(json_bf) print "data size: %s bytes"%len_json bf2 = BloomFilter.fromJSON(json_bf) assertListEquals(bf1.data, bf2.data) new_data = bf2.get_data() m = sum(state in bf2 for state in states) print('%d true positives out of %d trials' % (m, len(states))) trials = 100000 fp = 0 for trial in range(trials): while True: candidate = ''.join(sample(ascii_letters, 5)) # If we accidentally found a real state, try again if candidate in states: continue