@@ -58,7 +58,7 @@ def get_supported_metrics() -> list[MetricLiteral]:
5858 return list (get_args (MetricLiteral ))
5959
6060
61- def euclidean (** kwargs : dict [ str , Any ] ) -> Metric [Any ]:
61+ def euclidean () -> Metric [Any ]:
6262 """
6363 Return the Euclidean distance function for vectors.
6464
@@ -70,7 +70,7 @@ def euclidean(**kwargs: dict[str, Any]) -> Metric[Any]:
7070 return _metrics .euclidean
7171
7272
73- def manhattan (** kwargs : dict [ str , Any ] ) -> Metric [Any ]:
73+ def manhattan () -> Metric [Any ]:
7474 """
7575 Return the Manhattan distance function for vectors.
7676
@@ -82,7 +82,7 @@ def manhattan(**kwargs: dict[str, Any]) -> Metric[Any]:
8282 return _metrics .manhattan
8383
8484
85- def chebyshev (** kwargs : dict [ str , Any ] ) -> Metric [Any ]:
85+ def chebyshev () -> Metric [Any ]:
8686 """
8787 Return the Chebyshev distance function for vectors.
8888
@@ -94,7 +94,7 @@ def chebyshev(**kwargs: dict[str, Any]) -> Metric[Any]:
9494 return _metrics .chebyshev
9595
9696
97- def minkowski (** kwargs : dict [ str , Any ]) -> Metric [Any ]:
97+ def minkowski (p : Union [ int , float ]) -> Metric [Any ]:
9898 """
9999 Return the Minkowski distance function for order p on vectors.
100100
@@ -106,9 +106,6 @@ def minkowski(**kwargs: dict[str, Any]) -> Metric[Any]:
106106 :param p: The order of the Minkowski distance.
107107 :return: The Minkowski distance function.
108108 """
109- p = kwargs .get ("p" , 2 )
110- if not isinstance (p , (int , float )):
111- raise TypeError ("p must be an integer or a float" )
112109 if p == 1 :
113110 return manhattan ()
114111 if p == 2 :
@@ -122,7 +119,7 @@ def dist(x: Any, y: Any) -> float:
122119 return dist
123120
124121
125- def cosine (** kwargs : dict [ str , Any ] ) -> Metric [Any ]:
122+ def cosine () -> Metric [Any ]:
126123 """
127124 Return the cosine distance function for vectors.
128125
@@ -145,9 +142,7 @@ def cosine(**kwargs: dict[str, Any]) -> Metric[Any]:
145142 return _metrics .cosine
146143
147144
148- def get_metric (
149- metric : Union [MetricLiteral , Metric [Any ]], ** kwargs : dict [str , Any ]
150- ) -> Metric [Any ]:
145+ def get_metric (metric : Union [MetricLiteral , Metric [Any ]], ** kwargs : Any ) -> Metric [Any ]:
151146 """
152147 Return a distance function based on the specified string or callable.
153148
0 commit comments