summaryrefslogtreecommitdiff
path: root/test/test_ot.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_ot.py')
-rw-r--r--test/test_ot.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/test_ot.py b/test/test_ot.py
index dacae0a..4d59e12 100644
--- a/test/test_ot.py
+++ b/test/test_ot.py
@@ -118,6 +118,26 @@ def test_emd_empty():
np.testing.assert_allclose(w, 0)
+def test_emd_sparse():
+
+ n = 100
+ rng = np.random.RandomState(0)
+
+ x = rng.randn(n, 2)
+ x2 = rng.randn(n, 2)
+ u = ot.utils.unif(n)
+
+ M = ot.dist(x, x2)
+
+ G = ot.emd([], [], M)
+
+ Gs = ot.emd([], [], M, sparse=True)
+
+ # check G is the same
+ np.testing.assert_allclose(G, Gs.todense())
+ # check constraints
+
+
def test_emd2_multi():
n = 500 # nb bins