Skip to content

Commit d943406

Browse files
author
William de Vazelhes
committed
Add tolerance for triangular inequality because MMC probably projected onto a line
1 parent 72153ed commit d943406

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

test/test_mahalanobis_mixin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ def test_get_metric_is_pseudo_metric(estimator, build_dataset):
212212
# side of the equivalence is not always true for Mahalanobis distances.
213213
assert metric(a, a) == 0
214214
# triangular inequality
215-
assert metric(a, c) <= metric(a, b) + metric(b, c)
215+
assert (metric(a, c) < metric(a, b) + metric(b, c) or
216+
np.isclose(metric(a, c), metric(a, b) + metric(b, c), rtol=1e-20))
216217

217218

218219
@pytest.mark.parametrize('estimator, build_dataset', metric_learners,

0 commit comments

Comments
 (0)