MCPcopy Create free account
hub / github.com/catboost/catboost / test_mobius_transform_i8

Function test_mobius_transform_i8

library/python/hnsw/ut/test.py:183–210  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

181
182
183def test_mobius_transform_i8():
184 EPS = 1e-6
185 vectors = np.array(
186 [
187 [12, 13, 14, 15],
188 [125, 125, 125, 125],
189 [1, 0, 0, 0],
190 [-1, -1, -1, -1]
191 ],
192 np.int8
193 )
194 expected_vectors = [
195 [0.0163487738, 0.0177111717, 0.0190735695, 0.0204359673],
196 [0.002, 0.002, 0.002, 0.002],
197 [1, 0, 0, 0],
198 [-0.25, -0.25, -0.25, -0.25]
199 ]
200 vector_bytes = vectors.tobytes()
201 pool = Pool.from_bytes(vector_bytes, EVectorComponentType.I8, 4)
202 transformed_pool = transform_mobius(pool)
203 for i in range(transformed_pool.get_num_items()):
204 for j in range(transformed_pool.dimension):
205 assert abs(transformed_pool.get_item(i)[j] - expected_vectors[i][j]) < EPS
206 assert pool.get_item(i)[j] == vectors[i][j]
207 assert transformed_pool.dimension == 4
208 assert transformed_pool.get_num_items() == 4
209 assert transformed_pool.dtype == EVectorComponentType.Float
210 assert pool.dtype == EVectorComponentType.I8
211
212
213def test_mobius_transform_i32():

Callers

nothing calls this directly

Calls 7

transform_mobiusFunction · 0.90
from_bytesMethod · 0.80
rangeFunction · 0.50
absFunction · 0.50
arrayMethod · 0.45
get_num_itemsMethod · 0.45
get_itemMethod · 0.45

Tested by

no test coverage detected