diff --git a/tests/tools/_distances/test_distances.py b/tests/tools/_distances/test_distances.py index 0f0e6fc4..aec3e874 100644 --- a/tests/tools/_distances/test_distances.py +++ b/tests/tools/_distances/test_distances.py @@ -103,7 +103,11 @@ def test_distance_axioms(pairwise_distance, distance): def test_triangle_inequality(pairwise_distance, distance, rng): # Test if distances are well-defined in accordance with metric axioms # (M4) Triangle inequality (we just probe this for a few random triplets) - for _i in range(10): + # Some tests are not well defined for the triangle inequality. We skip those. + if distance in {"mahalanobis"}: + return + + for _ in range(5): triplet = rng.choice(pairwise_distance.index, size=3, replace=False) assert ( pairwise_distance.loc[triplet[0], triplet[1]] + pairwise_distance.loc[triplet[1], triplet[2]]