mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-03-26 08:29:48 +00:00
fix type
This commit is contained in:
parent
08bc970b7a
commit
044810991a
@ -45,7 +45,7 @@ class Bloom:
|
|||||||
|
|
||||||
def hash(self, value):
|
def hash(self, value):
|
||||||
res = 0b0
|
res = 0b0
|
||||||
for func in HASH_FUNCTIONS:
|
for func in self.HASH_FUNCTIONS:
|
||||||
b = func(value.encode()).digest()
|
b = func(value.encode()).digest()
|
||||||
position = int.from_bytes(b, "little") % self.size
|
position = int.from_bytes(b, "little") % self.size
|
||||||
res |= 2**position
|
res |= 2**position
|
||||||
@ -77,7 +77,7 @@ def test_probability(m=64, n=20):
|
|||||||
for a in added:
|
for a in added:
|
||||||
b.add(a)
|
b.add(a)
|
||||||
|
|
||||||
k = len(b.HASH_FUNCIONS)
|
k = len(b.HASH_FUNCTIONS)
|
||||||
|
|
||||||
n_ones = bin(b.bitstring).count("1")
|
n_ones = bin(b.bitstring).count("1")
|
||||||
expected_probability = (n_ones / m) ** k
|
expected_probability = (n_ones / m) ** k
|
||||||
|
Loading…
x
Reference in New Issue
Block a user