@@ -72,25 +72,25 @@ def __init__(self, size: int = 8) -> None:
72
72
self .size = size
73
73
74
74
def add (self , value : str ) -> None :
75
- h = self .hash_ (value )
75
+ h = self .hash (value )
76
76
self .bitarray |= h
77
77
78
78
def exists (self , value : str ) -> bool :
79
- h = self .hash_ (value )
79
+ h = self .hash (value )
80
80
return (h & self .bitarray ) == h
81
81
82
- def __contains__ (self , other ) :
82
+ def __contains__ (self , other : str ) -> bool :
83
83
return self .exists (other )
84
84
85
85
def format_bin (self , bitarray : int ) -> str :
86
86
res = bin (bitarray )[2 :]
87
87
return res .zfill (self .size )
88
88
89
89
@property
90
- def bitstring (self ):
90
+ def bitstring (self ) -> None :
91
91
return self .format_bin (self .bitarray )
92
92
93
- def hash_ (self , value : str ) -> int :
93
+ def hash (self , value : str ) -> int :
94
94
res = 0b0
95
95
for func in HASH_FUNCTIONS :
96
96
b = func (value .encode ()).digest ()
@@ -99,9 +99,9 @@ def hash_(self, value: str) -> int:
99
99
return res
100
100
101
101
def format_hash (self , value : str ) -> str :
102
- return self .format_bin (self .hash_ (value ))
102
+ return self .format_bin (self .hash (value ))
103
103
104
- def estimated_error_rate (self ):
104
+ def estimated_error_rate (self ) -> float :
105
105
n_ones = bin (self .bitarray ).count ("1" )
106
106
k = len (HASH_FUNCTIONS )
107
107
return (n_ones / self .size ) ** k
0 commit comments