Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4111807

Browse files
committed
passing ruff
1 parent 486dcbc commit 4111807

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

data_structures/hashing/bloom_filter.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""
22
See https://en.wikipedia.org/wiki/Bloom_filter
33
"""
4-
import string
54
from hashlib import md5, sha256
65
from random import choices
6+
from string import ascii_lowercase
77

88

99
class Bloom:
@@ -15,7 +15,7 @@ def __init__(self, size=8):
1515
self.size = size
1616

1717
def add(self, value):
18-
h = self.hash(value)
18+
h = self.hash_(value)
1919
self.bitstring |= h
2020
print(
2121
f"""\
@@ -26,7 +26,7 @@ def add(self, value):
2626
)
2727

2828
def exists(self, value):
29-
h = self.hash(value)
29+
h = self.hash_(value)
3030
res = (h & self.bitstring) == h
3131

3232
print(
@@ -43,7 +43,7 @@ def format_bin(self, value):
4343
res = bin(value)[2:]
4444
return res.zfill(self.size)
4545

46-
def hash(self, value):
46+
def hash_(self, value):
4747
res = 0b0
4848
for func in self.HASH_FUNCTIONS:
4949
b = func(value.encode()).digest()
@@ -67,7 +67,7 @@ def test_movies():
6767

6868

6969
def random_string(size):
70-
return "".join(choices(string.ascii_lowercase + " ", k=size))
70+
return "".join(choices(ascii_lowercase + " ", k=size))
7171

7272

7373
def test_probability(m=64, n=20):

0 commit comments

Comments
 (0)