Update data_structures/hashing/bloom_filter.py

Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
isidroas 2023-04-08 16:49:05 +02:00 committed by GitHub
parent 18e0dde13b
commit 54041ff38c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,22 +29,11 @@ because both hash functions return the same value
'01100100'
Not added elements should return False ...
>>> "The Goodfather" in bloom
>>> not_present_films = ("The Goodfather", "Interstellar", "Parasite", "Pulp Fiction")
>>> {film: bloom.format_hash(film) for film in not_present_films)}
{'The Goodfather': '00011000', 'Interstellar': '00000011', 'Parasite': '00010010': 'Pulp Fiction': '10000100'}
>>> any(film in bloom for film in not_present_films)
False
>>> bloom.format_hash("The Goodfather")
'00011000'
>>> "Interstellar" in bloom
False
>>> bloom.format_hash("Interstellar")
'00000011'
>>> "Parasite" in bloom
False
>>> bloom.format_hash("Parasite")
'00010010'
>>> "Pulp Fiction" in bloom
False
>>> bloom.format_hash("Pulp Fiction")
'10000100'
but sometimes there are false positives:
>>> "Ratatouille" in bloom