summaryrefslogtreecommitdiff
path: root/test/test_bregman.py
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/test_bregman.py
parent75fe96c183852971bb7be1da39af202b9f7d6e6c (diff)
parentc9b99df8fffec1dcc6802ef43b6192774817c5fb (diff)
Merge readme with master
Diffstat (limited to 'test/test_bregman.py')
-rw-r--r--test/test_bregman.py24
1 files changed, 24 insertions, 0 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