Skip to content

Commit 54041ff

Browse files
isidroascclauss
andauthored
Update data_structures/hashing/bloom_filter.py
Co-authored-by: Christian Clauss <[email protected]>
1 parent 18e0dde commit 54041ff

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

Diff for: data_structures/hashing/bloom_filter.py

+4-15
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,11 @@
2929
'01100100'
3030
3131
Not added elements should return False ...
32-
>>> "The Goodfather" in bloom
32+
>>> not_present_films = ("The Goodfather", "Interstellar", "Parasite", "Pulp Fiction")
33+
>>> {film: bloom.format_hash(film) for film in not_present_films)}
34+
{'The Goodfather': '00011000', 'Interstellar': '00000011', 'Parasite': '00010010': 'Pulp Fiction': '10000100'}
35+
>>> any(film in bloom for film in not_present_films)
3336
False
34-
>>> bloom.format_hash("The Goodfather")
35-
'00011000'
36-
>>> "Interstellar" in bloom
37-
False
38-
>>> bloom.format_hash("Interstellar")
39-
'00000011'
40-
>>> "Parasite" in bloom
41-
False
42-
>>> bloom.format_hash("Parasite")
43-
'00010010'
44-
>>> "Pulp Fiction" in bloom
45-
False
46-
>>> bloom.format_hash("Pulp Fiction")
47-
'10000100'
4837
4938
but sometimes there are false positives:
5039
>>> "Ratatouille" in bloom

0 commit comments

Comments
 (0)