Skip to content

Commit d594f45

Browse files
authored
[mypy] Add/fix type annotations for similarity search in machine learning (#4088)
* [mypy] Add/fix type annotations for similarity search in machine learning * fix annotation * fix annotation (Union) * isort
1 parent 7d26ba7 commit d594f45

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: machine_learning/similarity_search.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
2. distance between the vector and the nearest vector (float)
99
"""
1010
import math
11+
from typing import List, Union
1112

1213
import numpy as np
1314

@@ -30,7 +31,9 @@ def euclidean(input_a: np.ndarray, input_b: np.ndarray) -> float:
3031
return math.sqrt(sum(pow(a - b, 2) for a, b in zip(input_a, input_b)))
3132

3233

33-
def similarity_search(dataset: np.ndarray, value_array: np.ndarray) -> list:
34+
def similarity_search(
35+
dataset: np.ndarray, value_array: np.ndarray
36+
) -> List[List[Union[List[float], float]]]:
3437
"""
3538
:param dataset: Set containing the vectors. Should be ndarray.
3639
:param value_array: vector/vectors we want to know the nearest vector from dataset.

0 commit comments

Comments
 (0)