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

Function test_mobius_transform_i32

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

Source from the content-addressed store, hash-verified

211
212
213def test_mobius_transform_i32():
214 EPS = 1e-6
215 vectors = np.array(
216 [
217 [12, 13, -14, 15],
218 [1000000000, 1000000000, 1000000000, 1000000000],
219 [1, 0, 0, 0],
220 [-1, -1, -1, -1]
221 ],
222 np.int32
223 )
224 expected_vectors = [
225 [0.0163487738, 0.0177111717, -0.0190735695, 0.0204359673],
226 [1.25e-10, 1.25e-10, 1.25e-10, 1.25e-10],
227 [1, 0, 0, 0],
228 [-0.25, -0.25, -0.25, -0.25]
229 ]
230 vector_bytes = vectors.tobytes()
231 pool = Pool.from_bytes(vector_bytes, EVectorComponentType.I32, 4)
232 transformed_pool = Pool.from_bytes(bytes(0), EVectorComponentType.Float, 4)
233 transformed_pool = transform_mobius(pool)
234 for i in range(transformed_pool.get_num_items()):
235 for j in range(transformed_pool.dimension):
236 assert abs(transformed_pool.get_item(i)[j] - expected_vectors[i][j]) < EPS
237 assert pool.get_item(i)[j] == vectors[i][j]
238 assert transformed_pool.dimension == 4
239 assert transformed_pool.get_num_items() == 4
240 assert transformed_pool.dtype == EVectorComponentType.Float
241 assert pool.dtype == EVectorComponentType.I32
242
243
244@pytest.mark.parametrize('pool_params', POOL_PARAMS, ids=POOL_IDS)

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