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

Function test_mobius_transform_float

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

Source from the content-addressed store, hash-verified

150
151
152def test_mobius_transform_float():
153 EPS = 1e-6
154 vectors = np.array(
155 [
156 [0.1, 0.1, 0.1, 0.1],
157 [10.0, 10.0, 0.0, 0.0],
158 [1.0, 0.0, 0.0, 0.0],
159 [-1.0, -1.0, -1.0, -1.0]
160 ],
161 np.float32
162 )
163 expected_vectors = [
164 [2.5, 2.5, 2.5, 2.5],
165 [0.05, 0.05, 0, 0],
166 [1, 0, 0, 0],
167 [-0.25, -0.25, -0.25, -0.25]
168 ]
169 vector_bytes = vectors.tobytes()
170 pool = Pool.from_bytes(vector_bytes, EVectorComponentType.Float, 4)
171 transformed_pool = Pool.from_bytes(bytes(0), EVectorComponentType.Float, 4)
172 transformed_pool = transform_mobius(pool)
173 for i in range(transformed_pool.get_num_items()):
174 for j in range(transformed_pool.dimension):
175 assert abs(transformed_pool.get_item(i)[j] - expected_vectors[i][j]) < EPS
176 assert abs(pool.get_item(i)[j] - vectors[i][j]) < EPS
177 assert transformed_pool.dimension == 4
178 assert transformed_pool.get_num_items() == 4
179 assert transformed_pool.dtype == EVectorComponentType.Float
180 assert pool.dtype == EVectorComponentType.Float
181
182
183def test_mobius_transform_i8():

Callers

nothing calls this directly

Calls 8

transform_mobiusFunction · 0.90
bytesClass · 0.85
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