@@ -60,27 +60,27 @@ def test_space_main(self, space, dim):
60
60
61
61
p .num_threads = self .num_threads # by default using all available cores
62
62
63
- p0 = pickle .loads (pickle .dumps (p )) ### pickle un-initialized Index
63
+ p0 = pickle .loads (pickle .dumps (p )) # pickle un-initialized Index
64
64
p .init_index (max_elements = self .num_elements , ef_construction = self .ef_construction , M = self .M )
65
65
p0 .init_index (max_elements = self .num_elements , ef_construction = self .ef_construction , M = self .M )
66
66
67
67
p .ef = self .ef
68
68
p0 .ef = self .ef
69
69
70
- p1 = pickle .loads (pickle .dumps (p )) ### pickle Index before adding items
70
+ p1 = pickle .loads (pickle .dumps (p )) # pickle Index before adding items
71
71
72
- ### add items to ann index p,p0,p1
72
+ # add items to ann index p,p0,p1
73
73
p .add_items (data )
74
74
p1 .add_items (data )
75
75
p0 .add_items (data )
76
76
77
- p2 = pickle .loads (pickle .dumps (p )) ### pickle Index before adding items
77
+ p2 = pickle .loads (pickle .dumps (p )) # pickle Index before adding items
78
78
79
79
self .assertTrue (np .allclose (p .get_items (), p0 .get_items ()), "items for p and p0 must be same" )
80
80
self .assertTrue (np .allclose (p0 .get_items (), p1 .get_items ()), "items for p0 and p1 must be same" )
81
81
self .assertTrue (np .allclose (p1 .get_items (), p2 .get_items ()), "items for p1 and p2 must be same" )
82
82
83
- ### Test if returned distances are same
83
+ # Test if returned distances are same
84
84
l , d = p .knn_query (test_data , k = self .k )
85
85
l0 , d0 = p0 .knn_query (test_data , k = self .k )
86
86
l1 , d1 = p1 .knn_query (test_data , k = self .k )
@@ -90,8 +90,8 @@ def test_space_main(self, space, dim):
90
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
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" )
92
92
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
95
95
check_ann_results (self , space , data , test_data , self .k , l , d ,
96
96
err_thresh = self .label_err_thresh ,
97
97
total_thresh = self .item_err_thresh ,
@@ -102,19 +102,19 @@ def test_space_main(self, space, dim):
102
102
total_thresh = self .item_err_thresh ,
103
103
dists_thresh = self .dists_err_thresh )
104
104
105
- ### Check ef parameter value
105
+ # Check ef parameter value
106
106
self .assertEqual (p .ef , self .ef , "incorrect value of p.ef" )
107
107
self .assertEqual (p0 .ef , self .ef , "incorrect value of p0.ef" )
108
108
self .assertEqual (p2 .ef , self .ef , "incorrect value of p2.ef" )
109
109
self .assertEqual (p1 .ef , self .ef , "incorrect value of p1.ef" )
110
110
111
- ### Check M parameter value
111
+ # Check M parameter value
112
112
self .assertEqual (p .M , self .M , "incorrect value of p.M" )
113
113
self .assertEqual (p0 .M , self .M , "incorrect value of p0.M" )
114
114
self .assertEqual (p1 .M , self .M , "incorrect value of p1.M" )
115
115
self .assertEqual (p2 .M , self .M , "incorrect value of p2.M" )
116
116
117
- ### Check ef_construction parameter value
117
+ # Check ef_construction parameter value
118
118
self .assertEqual (p .ef_construction , self .ef_construction , "incorrect value of p.ef_construction" )
119
119
self .assertEqual (p0 .ef_construction , self .ef_construction , "incorrect value of p0.ef_construction" )
120
120
self .assertEqual (p1 .ef_construction , self .ef_construction , "incorrect value of p1.ef_construction" )
@@ -135,12 +135,12 @@ def setUp(self):
135
135
self .num_threads = 4
136
136
self .k = 25
137
137
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
140
140
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
144
144
145
145
def test_inner_product_space (self ):
146
146
test_space_main (self , 'ip' , 48 )
0 commit comments