diff options
author | Gard Spreemann <gspr@nonempty.org> | 2021-12-29 19:26:03 +0100 |
---|---|---|
committer | Gard Spreemann <gspr@nonempty.org> | 2021-12-29 19:26:03 +0100 |
commit | edab1c60630f95b38db430017585d06253c92817 (patch) | |
tree | 4cb2340c51157da0c81aae0907327417ffddd8ab /test/test_utils.py | |
parent | 1a283cb0c77f79d6f36de7c01fa61dc8d9696bca (diff) | |
parent | 5ed61689a41350fac40ce995515e6cbcb7203f48 (diff) |
Merge tag '0.8.1' into dfsg/latest
Diffstat (limited to 'test/test_utils.py')
-rw-r--r-- | test/test_utils.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/test_utils.py b/test/test_utils.py index 40f4e49..6b476b2 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -117,6 +117,26 @@ def test_dist(): np.testing.assert_allclose(D, D2, atol=1e-14) np.testing.assert_allclose(D, D3, atol=1e-14) + # tests that every metric runs correctly + metrics_w = [ + 'braycurtis', 'canberra', 'chebyshev', 'cityblock', 'correlation', 'cosine', 'dice', + 'euclidean', 'hamming', 'jaccard', 'kulsinski', + 'matching', 'minkowski', 'rogerstanimoto', 'russellrao', + 'sokalmichener', 'sokalsneath', 'sqeuclidean', 'wminkowski', 'yule' + ] # those that support weights + metrics = ['mahalanobis', 'seuclidean'] # do not support weights depending on scipy's version + + for metric in metrics_w: + print(metric) + ot.dist(x, x, metric=metric, p=3, w=np.random.random((2, ))) + for metric in metrics: + print(metric) + ot.dist(x, x, metric=metric, p=3) + + # weighted minkowski but with no weights + with pytest.raises(ValueError): + ot.dist(x, x, metric="wminkowski") + def test_dist_backends(nx): |