From 92233f79e098f1930248d815e66c0a929508af59 Mon Sep 17 00:00:00 2001 From: Kilian Date: Mon, 9 Dec 2019 15:56:48 +0100 Subject: add assert for emd dimension mismatch --- test/test_ot.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') 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 -- cgit v1.2.3 From 428b44e15591071cfcd69af365d878cfd876f9d3 Mon Sep 17 00:00:00 2001 From: Kilian Date: Mon, 9 Dec 2019 16:35:49 +0100 Subject: calling ot.emd test --- test/test_ot.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/test_ot.py b/test/test_ot.py index 1343604..25cdfd4 100644 --- a/test/test_ot.py +++ b/test/test_ot.py @@ -14,8 +14,9 @@ from ot.datasets import make_1D_gauss as gauss import pytest + def test_emd_dimension_mismatch(): - # test emd and emd2 for simple identity + # test emd and emd2 for dimension mismatch n_samples = 100 n_features = 2 rng = np.random.RandomState(0) @@ -25,9 +26,9 @@ def test_emd_dimension_mismatch(): M = ot.dist(x, x) - np.testing.assert_raises(AssertionError, emd, a, a, M) + np.testing.assert_raises(AssertionError, ot.emd, a, a, M) - np.testing.assert_raises(AssertionError, emd2, a, a, M) + np.testing.assert_raises(AssertionError, ot.emd2, a, a, M) def test_emd_emd2(): -- cgit v1.2.3 From 92dbe259032d340a259209e477e9aac74897689e Mon Sep 17 00:00:00 2001 From: Kilian Date: Mon, 9 Dec 2019 16:43:54 +0100 Subject: pep8 --- test/test_ot.py | 1 - 1 file changed, 1 deletion(-) (limited to 'test') diff --git a/test/test_ot.py b/test/test_ot.py index 25cdfd4..42a3d0a 100644 --- a/test/test_ot.py +++ b/test/test_ot.py @@ -14,7 +14,6 @@ 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 -- cgit v1.2.3