From 6d5176660754d49660605c15b9c0745d6ddb1864 Mon Sep 17 00:00:00 2001 From: Lucas Hosseini Date: Wed, 24 Feb 2021 11:51:03 -0800 Subject: [PATCH] Fix unused variables in python Reviewed By: mdouze Differential Revision: D26633983 fbshipit-source-id: 32b9f95ed9647716f65b93f2713a8d5bad6abe78 --- benchs/bench_all_ivf/parse_bench_all_ivf.py | 3 +-- benchs/bench_partition.py | 2 +- contrib/exhaustive_search.py | 1 - faiss/gpu/test/test_gpu_index.py | 3 --- tests/test_index.py | 2 +- tests/test_partition.py | 6 +++--- tests/test_standalone_codec.py | 6 ++---- 7 files changed, 8 insertions(+), 15 deletions(-) diff --git a/benchs/bench_all_ivf/parse_bench_all_ivf.py b/benchs/bench_all_ivf/parse_bench_all_ivf.py index 6e438c90c..08f6ca7f7 100644 --- a/benchs/bench_all_ivf/parse_bench_all_ivf.py +++ b/benchs/bench_all_ivf/parse_bench_all_ivf.py @@ -96,7 +96,7 @@ def parse_result_file(fname): assert False st = 1 elif 'index size on disk:' in l: - index_size = int(l.split()[-1]) + stats["index_size"] = int(l.split()[-1]) elif st == 1: st = 2 elif st == 2: @@ -256,7 +256,6 @@ def plot_tradeoffs(db, allres, allstats, code_size, recall_rank): stat0 = next(iter(allstats.values())) d = stat0["d"] n_threads = stat0["n_threads"] - nq = stat0["nq"] recall_idx = stat0["ranks"].index(recall_rank) # times come after the perf measure times_idx = len(stat0["ranks"]) diff --git a/benchs/bench_partition.py b/benchs/bench_partition.py index f6c715bd9..ce48ffe9a 100644 --- a/benchs/bench_partition.py +++ b/benchs/bench_partition.py @@ -40,7 +40,7 @@ def do_partition(n, qin, maxval=65536, seed=123, id_type='int64'): else: q_min, q_max = qin q = np.array([-1], dtype='uint64') - thresh2 = faiss.CMax_uint16_partition_fuzzy( + faiss.CMax_uint16_partition_fuzzy( tab_a.get(), sp(ids), n, q_min, q_max, sp(q) ) diff --git a/contrib/exhaustive_search.py b/contrib/exhaustive_search.py index 08d543318..e12ae827a 100644 --- a/contrib/exhaustive_search.py +++ b/contrib/exhaustive_search.py @@ -115,7 +115,6 @@ def range_ground_truth(xq, db_iterator, threshold, metric_type=faiss.METRIC_L2, i0 = 0 D = [[] for _i in range(nq)] I = [[] for _i in range(nq)] - all_lims = [] for xbi in db_iterator: ni = xbi.shape[0] if ngpu > 0: diff --git a/faiss/gpu/test/test_gpu_index.py b/faiss/gpu/test/test_gpu_index.py index 11d337db3..407bb0e5e 100755 --- a/faiss/gpu/test/test_gpu_index.py +++ b/faiss/gpu/test/test_gpu_index.py @@ -309,7 +309,6 @@ class TestIVFIndices(unittest.TestCase): res = faiss.StandardGpuResources() d = 128 nb = 5000 - nq = 10 nlist = 10 rs = np.random.RandomState(567) @@ -341,7 +340,6 @@ class TestIVFIndices(unittest.TestCase): res = faiss.StandardGpuResources() d = 128 nb = 5000 - nq = 10 nlist = 10 M = 4 nbits = 8 @@ -377,7 +375,6 @@ class TestIVFIndices(unittest.TestCase): res = faiss.StandardGpuResources() d = 128 nb = 5000 - nq = 10 nlist = 10 qtype = faiss.ScalarQuantizer.QT_4bit diff --git a/tests/test_index.py b/tests/test_index.py index 79640ff5a..712f33820 100644 --- a/tests/test_index.py +++ b/tests/test_index.py @@ -58,7 +58,7 @@ class TestIndexFlat(unittest.TestCase): for i in range(nq): l0, l1 = lims[i:i + 2] - Dl, Il = D2[l0:l1], I2[l0:l1] + _, Il = D2[l0:l1], I2[l0:l1] if metric_type == faiss.METRIC_L2: Ilref, = np.where(all_dis[i] < radius) else: diff --git a/tests/test_partition.py b/tests/test_partition.py index c3950410e..08087fb7c 100644 --- a/tests/test_partition.py +++ b/tests/test_partition.py @@ -160,12 +160,12 @@ class TestPartitioningUint16(unittest.TestCase, PartitionTests): # print("tab a type", tab_a.get()) if type(q) == int: - thresh2 = faiss.CMax_uint16_partition_fuzzy( + faiss.CMax_uint16_partition_fuzzy( tab_a.get(), sp(ids), n, q, q, None) else: q_min, q_max = q q = np.array([-1], dtype='uint64') - thresh2 = faiss.CMax_uint16_partition_fuzzy( + faiss.CMax_uint16_partition_fuzzy( tab_a.get(), sp(ids), n, q_min, q_max, sp(q) ) @@ -209,7 +209,7 @@ class TestPartitioningUint16Min(unittest.TestCase, PartitionTests): # print("tab a type", tab_a.get()) if type(q) == int: - thresh2 = faiss.CMin_uint16_partition_fuzzy( + faiss.CMin_uint16_partition_fuzzy( tab_a.get(), sp(ids), n, q, q, None) else: q_min, q_max = q diff --git a/tests/test_standalone_codec.py b/tests/test_standalone_codec.py index b3483c699..d7f89aca2 100644 --- a/tests/test_standalone_codec.py +++ b/tests/test_standalone_codec.py @@ -158,8 +158,8 @@ class TestAccuracy(unittest.TestCase): if 'Lattice' in highac: codec2 = faiss.deserialize_index( faiss.serialize_index(codec)) - codes = codec.sa_encode(x) - x3 = codec.sa_decode(codes) + codes = codec2.sa_encode(x) + x3 = codec2.sa_decode(codes) self.assertTrue(np.all(x2 == x3)) def test_SQ(self): @@ -208,8 +208,6 @@ class LatticeTest(unittest.TestCase): vecs = vec.copy() vecs.sort() repeats = faiss.Repeats(dim, swig_ptr(vecs)) - rr = [repeats.repeats.at(i) for i in range(repeats.repeats.size())] - # print([(r.val, r.n) for r in rr]) code = repeats.encode(swig_ptr(vec)) #print(vec, code) vec2 = np.zeros(dim, dtype='float32')