summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRémi Flamary <remi.flamary@gmail.com>2018-09-24 10:33:41 +0200
committerRémi Flamary <remi.flamary@gmail.com>2018-09-24 10:33:41 +0200
commit414331cbec21f00333e9de36a8790666c373e93c (patch)
tree5e5fab72c66d2e885c2d98bfc9567b527dfdb62e /test
parent75fe96c183852971bb7be1da39af202b9f7d6e6c (diff)
parentc9b99df8fffec1dcc6802ef43b6192774817c5fb (diff)
Merge readme with master
Diffstat (limited to 'test')
-rw-r--r--test/test_bregman.py24
-rw-r--r--test/test_stochastic.py8
2 files changed, 28 insertions, 4 deletions
diff --git a/test/test_bregman.py b/test/test_bregman.py
index 52bbbd2..58afd7a 100644
--- a/test/test_bregman.py
+++ b/test/test_bregman.py
@@ -108,6 +108,30 @@ def test_bary():
ot.bregman.barycenter(A, M, reg, log=True, verbose=True)
+def test_wassersteinbary():
+
+ size = 100 # size of a square image
+ a1 = np.random.randn(size, size)
+ a1 += a1.min()
+ a1 = a1 / np.sum(a1)
+ a2 = np.random.randn(size, size)
+ a2 += a2.min()
+ a2 = a2 / np.sum(a2)
+ # creating matrix A containing all distributions
+ A = np.zeros((2, 100, 100))
+ A[0, :, :] = a1
+ A[1, :, :] = a2
+
+ # wasserstein
+ reg = 1e-3
+ bary_wass = ot.bregman.convolutional_barycenter2d(A, reg)
+
+ np.testing.assert_allclose(1, np.sum(bary_wass))
+
+ # help in checking if log and verbose do not bug the function
+ ot.bregman.convolutional_barycenter2d(A, reg, log=True, verbose=True)
+
+
def test_unmix():
n_bins = 50 # nb bins
diff --git a/test/test_stochastic.py b/test/test_stochastic.py
index 0128317..f0f3fc8 100644
--- a/test/test_stochastic.py
+++ b/test/test_stochastic.py
@@ -32,7 +32,7 @@ def test_stochastic_sag():
# test sag
n = 15
reg = 1
- numItermax = 300000
+ numItermax = 30000
rng = np.random.RandomState(0)
x = rng.randn(n, 2)
@@ -62,7 +62,7 @@ def test_stochastic_asgd():
# test asgd
n = 15
reg = 1
- numItermax = 300000
+ numItermax = 100000
rng = np.random.RandomState(0)
x = rng.randn(n, 2)
@@ -92,7 +92,7 @@ def test_sag_asgd_sinkhorn():
# test all algorithms
n = 15
reg = 1
- nb_iter = 300000
+ nb_iter = 100000
rng = np.random.RandomState(0)
x = rng.randn(n, 2)
@@ -167,7 +167,7 @@ def test_dual_sgd_sinkhorn():
# test all dual algorithms
n = 10
reg = 1
- nb_iter = 150000
+ nb_iter = 15000
batch_size = 10
rng = np.random.RandomState(0)