@@ -55,11 +55,22 @@ def get_rho(w, max_width):
5555 return rho
5656
5757
58- def bit_length_vec (arr ):
59- # 64-bit safe
60- _ , high_exp = np .frexp (arr >> 32 )
61- _ , low_exp = np .frexp (arr & 0xFFFFFFFF )
62- return np .where (high_exp , high_exp + 32 , low_exp )
58+ # Check for NumPy 2.x
59+ if hasattr (np ,'bitwise_count' ):
60+ def bit_length_vec (arr ):
61+ bits = arr >> 1
62+ bits |= arr
63+ bits |= bits >> 2
64+ bits |= bits >> 4
65+ bits |= bits >> 8
66+ bits |= bits >> 16
67+ bits |= bits >> 32
68+ return np .bitwise_count (bits )
69+ else :
70+ def bit_length_vec (arr ):
71+ _ , high_exp = np .frexp (arr >> 32 )
72+ _ , low_exp = np .frexp (arr & 0xFFFFFFFF )
73+ return np .where (high_exp , high_exp + 32 , low_exp )
6374
6475
6576def get_rho_vec (w , max_width ):
@@ -119,8 +130,9 @@ def add(self, value):
119130 x = int .from_bytes (sha1 (packb (value )).digest ()[:8 ], byteorder = 'big' )
120131 j = x & (self .m - 1 )
121132 w = x >> self .p
133+ rho = get_rho (w , 64 - self .p )
122134
123- self .M [j ] = max (self .M [j ], get_rho ( w , 64 - self . p ) )
135+ self .M [j ] = max (self .M [j ], rho )
124136
125137 def add_bulk (self , values ):
126138 """
0 commit comments