Skip to content

Commit 28bea09

Browse files
committed
Fixes for weighted minkowski (per changes in SciPy); Scipy changed the name...
1 parent f80ee6f commit 28bea09

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

‎umap/tests/test_umap_metrics.py‎

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -493,24 +493,25 @@ def test_grad_metrics_match_metrics(spatial_data, spatial_distances):
493493
err_msg="Distances don't match " "for metric seuclidean",
494494
)
495495

496-
# Weighted minkowski
497-
dist_matrix = pairwise_distances(spatial_data, metric="wminkowski", w=v, p=3)
498-
test_matrix = np.array(
499-
[
496+
if scipy_full_version >= "1.8":
497+
# Weighted minkowski
498+
dist_matrix = pairwise_distances(spatial_data, metric="minkowski", w=v, p=3)
499+
test_matrix = np.array(
500500
[
501-
dist.weighted_minkowski_grad(spatial_data[i], spatial_data[j], v, p=3)[
502-
0
501+
[
502+
dist.weighted_minkowski_grad(spatial_data[i], spatial_data[j], v, p=3)[
503+
0
504+
]
505+
for j in range(spatial_data.shape[0])
503506
]
504-
for j in range(spatial_data.shape[0])
507+
for i in range(spatial_data.shape[0])
505508
]
506-
for i in range(spatial_data.shape[0])
507-
]
508-
)
509-
assert_array_almost_equal(
510-
test_matrix,
511-
dist_matrix,
512-
err_msg="Distances don't match " "for metric weighted_minkowski",
513-
)
509+
)
510+
assert_array_almost_equal(
511+
test_matrix,
512+
dist_matrix,
513+
err_msg="Distances don't match " "for metric weighted_minkowski",
514+
)
514515

515516
# Mahalanobis
516517
v = np.abs(np.random.randn(spatial_data.shape[1], spatial_data.shape[1]))

0 commit comments

Comments
 (0)