Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 104dede

Browse files
jjerphanogrisel
andauthored
TST Add some tests parametrization for test_neighbors (#22281)
Co-authored-by: Olivier Grisel <[email protected]>
1 parent 0b50b8e commit 104dede

File tree

3 files changed

+286
-169
lines changed

3 files changed

+286
-169
lines changed

sklearn/metrics/tests/test_dist_metrics.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def dist_func(x1, x2, p):
3939
VI = np.dot(V, V.T)
4040

4141
BOOL_METRICS = [
42+
"hamming",
4243
"matching",
4344
"jaccard",
4445
"dice",

sklearn/neighbors/_base.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from ..utils.multiclass import check_classification_targets
3333
from ..utils.validation import check_is_fitted
3434
from ..utils.validation import check_non_negative
35-
from ..utils.fixes import delayed
35+
from ..utils.fixes import delayed, sp_version
3636
from ..utils.fixes import parse_version
3737
from ..exceptions import DataConversionWarning, EfficiencyWarning
3838

@@ -63,11 +63,15 @@
6363
"sokalsneath",
6464
"sqeuclidean",
6565
"yule",
66-
"wminkowski",
6766
]
6867
),
6968
)
7069

70+
# TODO: Remove filterwarnings in 1.3 when wminkowski is removed
71+
if sp_version < parse_version("1.8.0.dev0"):
72+
# Before scipy 1.8.0.dev0, wminkowski was the key to use
73+
# the weighted minkowski metric.
74+
VALID_METRICS["brute"].append("wminkowski")
7175

7276
VALID_METRICS_SPARSE = dict(
7377
ball_tree=[],

0 commit comments

Comments
 (0)