From 4111807c4708c08fb56408b7e87d9473debfe824 Mon Sep 17 00:00:00 2001 From: Isidro Arias Date: Thu, 6 Apr 2023 13:46:21 +0200 Subject: [PATCH] passing ruff --- data_structures/hashing/bloom_filter.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/data_structures/hashing/bloom_filter.py b/data_structures/hashing/bloom_filter.py index 74db6e2a1..c39c65433 100644 --- a/data_structures/hashing/bloom_filter.py +++ b/data_structures/hashing/bloom_filter.py @@ -1,9 +1,9 @@ """ See https://en.wikipedia.org/wiki/Bloom_filter """ -import string from hashlib import md5, sha256 from random import choices +from string import ascii_lowercase class Bloom: @@ -15,7 +15,7 @@ class Bloom: self.size = size def add(self, value): - h = self.hash(value) + h = self.hash_(value) self.bitstring |= h print( f"""\ @@ -26,7 +26,7 @@ class Bloom: ) def exists(self, value): - h = self.hash(value) + h = self.hash_(value) res = (h & self.bitstring) == h print( @@ -43,7 +43,7 @@ class Bloom: res = bin(value)[2:] return res.zfill(self.size) - def hash(self, value): + def hash_(self, value): res = 0b0 for func in self.HASH_FUNCTIONS: b = func(value.encode()).digest() @@ -67,7 +67,7 @@ def test_movies(): def random_string(size): - return "".join(choices(string.ascii_lowercase + " ", k=size)) + return "".join(choices(ascii_lowercase + " ", k=size)) def test_probability(m=64, n=20):