Skip to content

Commit

Permalink
Merge pull request #12 from trufae/lintfix
Browse files Browse the repository at this point in the history
Fix pylint complains
  • Loading branch information
vprelovac authored Jan 11, 2024
2 parents 8bfc71d + 26df010 commit e453700
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions vectordb/vector_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from typing import List, Tuple
import numpy as np
import faiss
import sklearn


MRPT_LOADED = True
Expand All @@ -28,6 +27,9 @@ class VectorSearch:

@staticmethod
def get_unique_k_elements(i, d, k=15, diverse=False):
"""
Return a tuple of arrays containing unique matching elements
"""
ii, dd = [], []
num_rows, num_cols = i.shape

Expand Down Expand Up @@ -72,11 +74,10 @@ def run_mrpt(vector, vectors, k=15, batch_results="flatten"):
)

return VectorSearch.get_unique_k_elements(res[0], res[1], k, diverse=False)
else:
res = index.exact_search(
np.array(vector).astype(np.float32), k, return_distances=True
)
return res[0].tolist(), res[1].tolist()
res = index.exact_search(
np.array(vector).astype(np.float32), k, return_distances=True
)
return res[0].tolist(), res[1].tolist()

@staticmethod
def run_faiss(vector, vectors, k=15, batch_results="flatten"):
Expand All @@ -95,9 +96,8 @@ def run_faiss(vector, vectors, k=15, batch_results="flatten"):
if batch_results == "diverse":
return VectorSearch.get_unique_k_elements(indices, dis, k, diverse=True)
return VectorSearch.get_unique_k_elements(indices, dis, k, diverse=False)
else:
dis, indices = index.search(np.array([vector]), k)
return indices[0], dis[0]
dis, indices = index.search(np.array([vector]), k)
return indices[0], dis[0]

@staticmethod
def search_vectors(
Expand Down

0 comments on commit e453700

Please sign in to comment.