hora icon indicating copy to clipboard operation
hora copied to clipboard

Possible alternative to 'add'

Open apiszcz opened this issue 3 years ago • 2 comments

The current index add method adds a single vector. Is it possible to add 2D numpy array of vectors and use the array row position as the index.

# proposal for consideration
a = np.array([[1,2,3],[4,5,6]]
index.add(a)
# currently
for i in a:
   index.add(sample, i).unwrap();

apiszcz avatar Aug 01 '21 09:08 apiszcz

great advice, I would add it next version as soon as possible!

salamer avatar Aug 01 '21 14:08 salamer

Thanks that will save one loop through the data. SCIKIT KDtree uses the full arrayby default. https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KDTree.html

apiszcz avatar Aug 01 '21 14:08 apiszcz