diff --git a/Index.h b/Index.h index 7c41f87dd..b6098093c 100644 --- a/Index.h +++ b/Index.h @@ -18,7 +18,7 @@ #define FAISS_VERSION_MAJOR 1 #define FAISS_VERSION_MINOR 6 -#define FAISS_VERSION_PATCH 0 +#define FAISS_VERSION_PATCH 1 /** * @namespace faiss diff --git a/benchs/bench_all_ivf/datasets.py b/benchs/bench_all_ivf/datasets.py index 63377bc9a..9f9064321 100644 --- a/benchs/bench_all_ivf/datasets.py +++ b/benchs/bench_all_ivf/datasets.py @@ -64,6 +64,7 @@ def fvecs_write(fname, m): ivecs_write(fname, m.view('int32')) + ################################################################# # Dataset ################################################################# diff --git a/benchs/distributed_ondisk/README.md b/benchs/distributed_ondisk/README.md index 643a99a1d..c2c792992 100644 --- a/benchs/distributed_ondisk/README.md +++ b/benchs/distributed_ondisk/README.md @@ -1,3 +1,4 @@ + # Distributed on-disk index for 1T-scale datasets This is code corresponding to the description in [Indexing 1T vectors](https://github.com/facebookresearch/faiss/wiki/Indexing-1T-vectors). diff --git a/benchs/distributed_ondisk/combined_index.py b/benchs/distributed_ondisk/combined_index.py index c2583bc45..3df2a0180 100644 --- a/benchs/distributed_ondisk/combined_index.py +++ b/benchs/distributed_ondisk/combined_index.py @@ -3,6 +3,8 @@ # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. +#!/usr/bin/env python3 + import os import faiss import numpy as np @@ -29,7 +31,7 @@ class CombinedIndex: indexes.append(index) il = faiss.extract_index_ivf(index).invlists else: - assert False + raise AssertionError ilv.push_back(il) print() diff --git a/benchs/distributed_ondisk/distributed_kmeans.py b/benchs/distributed_ondisk/distributed_kmeans.py index 423f88127..ae7a292d3 100644 --- a/benchs/distributed_ondisk/distributed_kmeans.py +++ b/benchs/distributed_ondisk/distributed_kmeans.py @@ -2,6 +2,7 @@ # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. + #! /usr/bin/env python3 """ @@ -356,7 +357,7 @@ def main(): elif args.indata.endswith('.npy'): x = np.load(args.indata, mmap_mode='r') else: - assert False + raise AssertionError if args.i1 == -1: args.i1 = len(x) @@ -386,7 +387,8 @@ def main(): True ) else: - assert False + raise AssertionError + if args.server: print('starting server') diff --git a/benchs/distributed_ondisk/distributed_query_demo.py b/benchs/distributed_ondisk/distributed_query_demo.py index 401f05605..9453c0ec2 100644 --- a/benchs/distributed_ondisk/distributed_query_demo.py +++ b/benchs/distributed_ondisk/distributed_query_demo.py @@ -2,6 +2,7 @@ # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. + import os import faiss import numpy as np diff --git a/benchs/distributed_ondisk/make_index_vslice.py b/benchs/distributed_ondisk/make_index_vslice.py index 336491940..ca58425b2 100644 --- a/benchs/distributed_ondisk/make_index_vslice.py +++ b/benchs/distributed_ondisk/make_index_vslice.py @@ -2,6 +2,7 @@ # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. + import os import time import numpy as np diff --git a/benchs/distributed_ondisk/merge_to_ondisk.py b/benchs/distributed_ondisk/merge_to_ondisk.py index 735c92b2a..5c8f3ace9 100644 --- a/benchs/distributed_ondisk/merge_to_ondisk.py +++ b/benchs/distributed_ondisk/merge_to_ondisk.py @@ -49,7 +49,7 @@ if __name__ == '__main__': index0 = None - for fname, index in pool.imap(load_index, args.inputs): + for _, index in pool.imap(load_index, args.inputs): if index is None: continue index_ivf = faiss.extract_index_ivf(index) diff --git a/benchs/distributed_ondisk/rpc.py b/benchs/distributed_ondisk/rpc.py index 401d0d5bc..7b248ea0a 100644 --- a/benchs/distributed_ondisk/rpc.py +++ b/benchs/distributed_ondisk/rpc.py @@ -2,6 +2,9 @@ # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. + +#!/usr/bin/env python3 + """ Simplistic RPC implementation. Exposes all functions of a Server object. @@ -163,7 +166,7 @@ class Server: except EOFError: self.log("EOF during communication") traceback.print_exc(50,self.logf) - except: + except BaseException: # unexpected traceback.print_exc(50,sys.stderr) sys.exit(1) diff --git a/benchs/distributed_ondisk/search_server.py b/benchs/distributed_ondisk/search_server.py index 28c5efbdd..9239afd59 100644 --- a/benchs/distributed_ondisk/search_server.py +++ b/benchs/distributed_ondisk/search_server.py @@ -2,6 +2,7 @@ # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. + import os import time import rpc diff --git a/clone_index.cpp b/clone_index.cpp index 918ad11a2..79f0e9968 100644 --- a/clone_index.cpp +++ b/clone_index.cpp @@ -107,6 +107,12 @@ Index *Cloner::clone_Index (const Index *index) dynamic_cast (index)) { IndexPreTransform *res = new IndexPreTransform (); res->d = ipt->d; + res->ntotal = ipt->ntotal; + res->is_trained = ipt->is_trained; + res->metric_type = ipt->metric_type; + res->metric_arg = ipt->metric_arg; + + res->index = clone_Index (ipt->index); for (int i = 0; i < ipt->chain.size(); i++) res->chain.push_back (clone_VectorTransform (ipt->chain[i])); diff --git a/python/faiss.py b/python/faiss.py index cc0ea4d32..924fbba6e 100644 --- a/python/faiss.py +++ b/python/faiss.py @@ -8,8 +8,6 @@ # not linting this file because it imports * form swigfaiss, which # causes a ton of useless warnings. -from __future__ import print_function - import numpy as np import sys import inspect @@ -47,7 +45,7 @@ try: except ImportError: # we import * so that the symbol X can be accessed as faiss.X - logger.error("Loading faiss.") + logger.info("Loading faiss.") from .swigfaiss import * diff --git a/python/setup.py b/python/setup.py index 592f3730e..f4c47eb3d 100644 --- a/python/setup.py +++ b/python/setup.py @@ -32,7 +32,7 @@ are implemented on the GPU. It is developed by Facebook AI Research. """ setup( name='faiss', - version='1.6.0', + version='1.6.1', description='A library for efficient similarity search and clustering of dense vectors', long_description=long_description, url='https://github.com/facebookresearch/faiss', diff --git a/tests/test_factory.py b/tests/test_factory.py index 968d52cea..05c62fd80 100644 --- a/tests/test_factory.py +++ b/tests/test_factory.py @@ -5,10 +5,13 @@ #! /usr/bin/env python2 +import numpy as np import unittest import faiss + + class TestFactory(unittest.TestCase): def test_factory_1(self): @@ -50,3 +53,15 @@ class TestFactory(unittest.TestCase): def test_factory_4(self): index = faiss.index_factory(12, "IVF10,FlatDedup") assert index.instances is not None + + + +class TestCloneSize(unittest.TestCase): + + def test_clone_size(self): + index = faiss.index_factory(20, 'PCA10,Flat') + xb = faiss.rand((100, 20)) + index.train(xb) + index.add(xb) + index2 = faiss.clone_index(index) + assert index2.ntotal == 100