@@ -246,45 +246,19 @@ def test_merge_IDMap2(self):
246246
247247class TestRemoveFastScan (unittest .TestCase ):
248248
249- def do_fast_scan_test (self ,
250- factory_key ,
251- with_ids = False ,
252- direct_map_type = faiss .DirectMap .NoMap ):
249+ def do_fast_scan_test (self , factory_key , size1 ):
253250 ds = SyntheticDataset (110 , 1000 , 1000 , 100 )
254- index = faiss .index_factory (ds .d , factory_key )
255- index .train (ds .get_train ())
256-
257- index .reset ()
251+ index1 = faiss .index_factory (ds .d , factory_key )
252+ index1 .train (ds .get_train ())
253+ index1 .reset ()
258254 tokeep = [i % 3 == 0 for i in range (ds .nb )]
259- if with_ids :
260- index .add_with_ids (ds .get_database ()[tokeep ], np .arange (ds .nb )[tokeep ])
261- faiss .extract_index_ivf (index ).nprobe = 5
262- else :
263- index .add (ds .get_database ()[tokeep ])
264- _ , Iref = index .search (ds .get_queries (), 5 )
265-
266- index .reset ()
267- if with_ids :
268- index .add_with_ids (ds .get_database (), np .arange (ds .nb ))
269- index .set_direct_map_type (direct_map_type )
270- faiss .extract_index_ivf (index ).nprobe = 5
271- else :
272- index .add (ds .get_database ())
273- index .remove_ids (np .where (np .logical_not (tokeep ))[0 ])
274- _ , Inew = index .search (ds .get_queries (), 5 )
255+ index1 .add (ds .get_database ()[tokeep ])
256+ _ , Iref = index1 .search (ds .get_queries (), 5 )
257+ index1 .reset ()
258+ index1 .add (ds .get_database ())
259+ index1 .remove_ids (np .where (np .logical_not (tokeep ))[0 ])
260+ _ , Inew = index1 .search (ds .get_queries (), 5 )
275261 np .testing .assert_array_equal (Inew , Iref )
276262
277- def test_remove_PQFastScan (self ):
278- # with_ids is not support for this type of index
279- self .do_fast_scan_test ("PQ5x4fs" , False )
280-
281- def test_remove_IVFPQFastScan (self ):
282- self .do_fast_scan_test ("IVF20,PQ5x4fs" , True )
283-
284- def test_remove_IVFPQFastScan_2 (self ):
285- self .assertRaisesRegex (Exception ,
286- ".*not supported.*" ,
287- self .do_fast_scan_test ,
288- "IVF20,PQ5x4fs" ,
289- True ,
290- faiss .DirectMap .Hashtable )
263+ def test_remove (self ):
264+ self .do_fast_scan_test ("PQ5x4fs" , 320 )
0 commit comments