def test_run2(): ''' Parameters ---------- checks: number of nodes to check (?) ''' n = 100 k = 3 ops = 10 test_n = 1 x = random_vectors(n) test_points = random_vectors(test_n) index = Index(x, w=(0.5, 0.5)) for i in range(n // ops): ur = index.run(ops) print(ur) ids1, dists1 = index.knn_search_points(test_points, k, checks=1) # ids2, dists2 = index.knn_search_points(test_points, k, checks = 50) ids3, dists3 = index.knn_search_points(test_points, k, checks=100) print("1: ", ids1) print("1: ", dists1) # print("2: ", ids2) print("3: ", ids3) print("3: ", dists3) print(index.size())
def test_run(): """ RUN ---------- INCREMENTALLY ADD POINTS TO THE TREE STRUCTURE Parameters ---------- ops: number of ops Returns ------- numPointsInserted: total number of points inserted addPointOps: number of ops allocated to add updateIndexOps: number of ops allocated to update index addPointResult: number of added points updateIndexResult: ? addPointElapsed: time elapsed for add updateIndexElapsed: time elapsed for update index """ x = random_vectors(n=30, d=3) index = Index(x, w=(0.5, 0.5)) ops = 6 for i in range(x.shape[0] // ops): ur = index.run(ops) print("===========") print("index.size(): ", index.size()) # index.size grows as we run iteratively print(ur)
def test_add_points(): """ ADD_POINTS ---------- WE MUST ADD POINTS BEFORE QUERYING THE INDEX Parameters ---------- ops: number of points to add """ x = random_vectors(n=30) index = Index(x) print(index.size()) # 0 since we did not add any points index.add_points(1) # add 1 point print(index.size()) # 1 index.add_points(100000) print(index.size()) # 30 since we cannot add more than we have
def test_incremental_run1(self): x = random_vectors() index = Index(x, w=(0.5, 0.5)) self.assertTrue(index.is_using_pyarray) ops = 20 for i in range(x.shape[0] // ops): ur = index.run(ops) self.assertEqual(index.size(), (i + 1) * ops) self.assertEqual(ur['addPointResult'], ops)