summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRĂ©mi Flamary <remi.flamary@gmail.com>2020-01-20 11:44:07 +0100
committerGitHub <noreply@github.com>2020-01-20 11:44:07 +0100
commit1b58440457b25aace9dac56aa21144286e60f16e (patch)
tree2622569a36aab5fc2eb2d2adc45a16f861a65dc5 /test
parentc5039bcafde999114283f7e59fb03e176027d740 (diff)
parent40154746a5a6cab0b6f17c284967eb8303fcc3f6 (diff)
Merge pull request #116 from kilianFatras/emd_dimension
[MRG] Add assert for emd dimension mismatch
Diffstat (limited to 'test')
-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 3dd544c..18b6294 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 dimension mismatch
+ 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, ot.emd, a, a, M)
+
+ np.testing.assert_raises(AssertionError, ot.emd2, a, a, M)
+
+
def test_emd_emd2():
# test emd and emd2 for simple identity
n = 100