@@ -1535,7 +1535,9 @@ def test_neighbors_metrics(
1535
1535
and algorithm == "brute"
1536
1536
and sp_version >= parse_version ("1.6.0" )
1537
1537
):
1538
- with pytest .warns (FutureWarning ):
1538
+ with pytest .warns ((FutureWarning , DeprecationWarning )):
1539
+ # For float64 WMinkowskiDistance raises a FutureWarning,
1540
+ # for float32 scipy raises a DeprecationWarning
1539
1541
results [algorithm ] = neigh .kneighbors (X_test , return_distance = True )
1540
1542
else :
1541
1543
results [algorithm ] = neigh .kneighbors (X_test , return_distance = True )
@@ -1578,12 +1580,9 @@ def test_kneighbors_brute_backend(
1578
1580
# wminkoski is deprecated in SciPy 1.6.0 and removed in 1.8.0
1579
1581
warn_context_manager = nullcontext ()
1580
1582
if metric == "wminkowski" and sp_version >= parse_version ("1.6.0" ):
1581
- if global_dtype == np .float64 :
1582
- # Warning from sklearn.metrics._dist_metrics.WMinkowskiDistance
1583
- warn_context_manager = pytest .warns (FutureWarning )
1584
- if global_dtype == np .float32 :
1585
- # Warning from Scipy
1586
- warn_context_manager = pytest .warns (DeprecationWarning )
1583
+ # For float64 WMinkowskiDistance raises a FutureWarning,
1584
+ # for float32 scipy raises a DeprecationWarning
1585
+ warn_context_manager = pytest .warns ((FutureWarning , DeprecationWarning ))
1587
1586
1588
1587
for metric_params in metric_params_list :
1589
1588
p = metric_params .pop ("p" , 2 )
@@ -1597,6 +1596,7 @@ def test_kneighbors_brute_backend(
1597
1596
)
1598
1597
1599
1598
neigh .fit (X_train )
1599
+
1600
1600
with warn_context_manager :
1601
1601
with config_context (enable_cython_pairwise_dist = False ):
1602
1602
# Use the legacy backend for brute
@@ -2105,7 +2105,9 @@ def test_radius_neighbors_brute_backend(
2105
2105
# wminkoski is deprecated in SciPy 1.6.0 and removed in 1.8.0
2106
2106
warn_context_manager = nullcontext ()
2107
2107
if metric == "wminkowski" and sp_version >= parse_version ("1.6.0" ):
2108
- warn_context_manager = pytest .warns (FutureWarning )
2108
+ # For float64 WMinkowskiDistance raises a FutureWarning,
2109
+ # for float32 scipy raises a DeprecationWarning
2110
+ warn_context_manager = pytest .warns ((FutureWarning , DeprecationWarning ))
2109
2111
2110
2112
for metric_params in metric_params_list :
2111
2113
p = metric_params .pop ("p" , 2 )
0 commit comments