summaryrefslogtreecommitdiff
path: root/test/test_ot.py
diff options
context:
space:
mode:
authorKilian <kilian.fatras@gmail.com>2019-12-09 15:56:48 +0100
committerKilian <kilian.fatras@gmail.com>2019-12-09 15:56:48 +0100
commit92233f79e098f1930248d815e66c0a929508af59 (patch)
tree8fe65a25c54c41eb2d8753250fb13ebf41ba9ffa /test/test_ot.py
parent0280a3441b09c781035cda3b74213ec92026ff9e (diff)
add assert for emd dimension mismatch
Diffstat (limited to 'test/test_ot.py')
-rw-r--r--test/test_ot.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/test_ot.py b/test/test_ot.py
index dacae0a..1343604 100644
--- a/test/test_ot.py
+++ b/test/test_ot.py
@@ -14,6 +14,22 @@ from ot.datasets import make_1D_gauss as gauss
import pytest
+def test_emd_dimension_mismatch():
+ # test emd and emd2 for simple identity
+ n_samples = 100
+ n_features = 2
+ rng = np.random.RandomState(0)
+
+ x = rng.randn(n_samples, n_features)
+ a = ot.utils.unif(n_samples + 1)
+
+ M = ot.dist(x, x)
+
+ np.testing.assert_raises(AssertionError, emd, a, a, M)
+
+ np.testing.assert_raises(AssertionError, emd2, a, a, M)
+
+
def test_emd_emd2():
# test emd and emd2 for simple identity
n = 100