@@ -60,38 +60,38 @@ def test_space_main(self, space, dim):
6060
6161 p .num_threads = self .num_threads # by default using all available cores
6262
63- p0 = pickle .loads (pickle .dumps (p )) ### pickle un-initialized Index
63+ p0 = pickle .loads (pickle .dumps (p )) # pickle un-initialized Index
6464 p .init_index (max_elements = self .num_elements , ef_construction = self .ef_construction , M = self .M )
6565 p0 .init_index (max_elements = self .num_elements , ef_construction = self .ef_construction , M = self .M )
6666
6767 p .ef = self .ef
6868 p0 .ef = self .ef
6969
70- p1 = pickle .loads (pickle .dumps (p )) ### pickle Index before adding items
70+ p1 = pickle .loads (pickle .dumps (p )) # pickle Index before adding items
7171
72- ### add items to ann index p,p0,p1
72+ # add items to ann index p,p0,p1
7373 p .add_items (data )
7474 p1 .add_items (data )
7575 p0 .add_items (data )
7676
77- p2 = pickle .loads (pickle .dumps (p )) ### pickle Index before adding items
77+ p2 = pickle .loads (pickle .dumps (p )) # pickle Index before adding items
7878
7979 self .assertTrue (np .allclose (p .get_items (), p0 .get_items ()), "items for p and p0 must be same" )
8080 self .assertTrue (np .allclose (p0 .get_items (), p1 .get_items ()), "items for p0 and p1 must be same" )
8181 self .assertTrue (np .allclose (p1 .get_items (), p2 .get_items ()), "items for p1 and p2 must be same" )
8282
83- ### Test if returned distances are same
83+ # Test if returned distances are same
8484 l , d = p .knn_query (test_data , k = self .k )
8585 l0 , d0 = p0 .knn_query (test_data , k = self .k )
8686 l1 , d1 = p1 .knn_query (test_data , k = self .k )
8787 l2 , d2 = p2 .knn_query (test_data , k = self .k )
8888
89- self .assertLessEqual (np .sum (((d - d0 )** 2. )> 1e-3 ), self .dists_err_thresh , msg = f"knn distances returned by p and p0 must match" )
90- self .assertLessEqual (np .sum (((d0 - d1 )** 2. )> 1e-3 ), self .dists_err_thresh , msg = f"knn distances returned by p0 and p1 must match" )
91- self .assertLessEqual (np .sum (((d1 - d2 )** 2. )> 1e-3 ), self .dists_err_thresh , msg = f"knn distances returned by p1 and p2 must match" )
89+ self .assertLessEqual (np .sum (((d - d0 )** 2. ) > 1e-3 ), self .dists_err_thresh , msg = f"knn distances returned by p and p0 must match" )
90+ self .assertLessEqual (np .sum (((d0 - d1 )** 2. ) > 1e-3 ), self .dists_err_thresh , msg = f"knn distances returned by p0 and p1 must match" )
91+ self .assertLessEqual (np .sum (((d1 - d2 )** 2. ) > 1e-3 ), self .dists_err_thresh , msg = f"knn distances returned by p1 and p2 must match" )
9292
93- ### check if ann results match brute-force search
94- ### allow for 2 labels to be missing from ann results
93+ # check if ann results match brute-force search
94+ # allow for 2 labels to be missing from ann results
9595 check_ann_results (self , space , data , test_data , self .k , l , d ,
9696 err_thresh = self .label_err_thresh ,
9797 total_thresh = self .item_err_thresh ,
@@ -102,19 +102,19 @@ def test_space_main(self, space, dim):
102102 total_thresh = self .item_err_thresh ,
103103 dists_thresh = self .dists_err_thresh )
104104
105- ### Check ef parameter value
105+ # Check ef parameter value
106106 self .assertEqual (p .ef , self .ef , "incorrect value of p.ef" )
107107 self .assertEqual (p0 .ef , self .ef , "incorrect value of p0.ef" )
108108 self .assertEqual (p2 .ef , self .ef , "incorrect value of p2.ef" )
109109 self .assertEqual (p1 .ef , self .ef , "incorrect value of p1.ef" )
110110
111- ### Check M parameter value
111+ # Check M parameter value
112112 self .assertEqual (p .M , self .M , "incorrect value of p.M" )
113113 self .assertEqual (p0 .M , self .M , "incorrect value of p0.M" )
114114 self .assertEqual (p1 .M , self .M , "incorrect value of p1.M" )
115115 self .assertEqual (p2 .M , self .M , "incorrect value of p2.M" )
116116
117- ### Check ef_construction parameter value
117+ # Check ef_construction parameter value
118118 self .assertEqual (p .ef_construction , self .ef_construction , "incorrect value of p.ef_construction" )
119119 self .assertEqual (p0 .ef_construction , self .ef_construction , "incorrect value of p0.ef_construction" )
120120 self .assertEqual (p1 .ef_construction , self .ef_construction , "incorrect value of p1.ef_construction" )
@@ -135,12 +135,12 @@ def setUp(self):
135135 self .num_threads = 4
136136 self .k = 25
137137
138- self .label_err_thresh = 5 ### max number of missing labels allowed per test item
139- self .item_err_thresh = 5 ### max number of items allowed with incorrect labels
138+ self .label_err_thresh = 5 # max number of missing labels allowed per test item
139+ self .item_err_thresh = 5 # max number of items allowed with incorrect labels
140140
141- self .dists_err_thresh = 50 ### for two matrices, d1 and d2, dists_err_thresh controls max
142- ### number of value pairs that are allowed to be different in d1 and d2
143- ### i.e., number of values that are (d1-d2)**2>1e-3
141+ self .dists_err_thresh = 50 # for two matrices, d1 and d2, dists_err_thresh controls max
142+ # number of value pairs that are allowed to be different in d1 and d2
143+ # i.e., number of values that are (d1-d2)**2>1e-3
144144
145145 def test_inner_product_space (self ):
146146 test_space_main (self , 'ip' , 48 )
0 commit comments