def test_dump_load(self): fd = BIndexer(self.toy_data.shape[1], data_path=self.dump_path + '_3') fd.add(self.toy_label, self.toy_data, self.weights) fd.dump() fd.close() # shutil.rmtree(self.data_path + "_3") fd2 = BIndexer.load(fd.dump_full_path) rs = fd2.query(self.toy_query, 2, normalized_score=False) for i in range(len(rs)): rs[i] = sorted(rs[i], key=lambda x: (x[3], -x[0])) fd2.close() self.assertEqual(rs, self.toy_exp) os.remove(self.dump_path + '_3')
def test_nsw_search(self): fd = BIndexer(self.toy_data.shape[1], data_path=self.dump_path + '_1') fd.add(self.toy_label, self.toy_data, self.weights) rs = fd.query(self.toy_query, 2, method='nsw', normalized_score=False) for i in range(len(rs)): rs[i] = sorted(rs[i], key=lambda x: (x[3], -x[0])) fd.close() self.assertEqual(rs, self.toy_exp)