Skip to content

Commit 3e7eb43

Browse files
committed
test wasserstein barycenter
1 parent dab5723 commit 3e7eb43

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/test_bregman.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,30 @@ def test_bary():
105105
ot.bregman.barycenter(A, M, reg, log=True, verbose=True)
106106

107107

108+
def test_wassersteinbary():
109+
110+
size = 100 # size of a square image
111+
a1 = np.random.randn(size, size)
112+
a1 += a1.min()
113+
a1 = a1 / np.sum(a1)
114+
a2 = np.random.randn(size, size)
115+
a2 += a2.min()
116+
a2 = a2 / np.sum(a2)
117+
# creating matrix A containing all distributions
118+
A = np.zeros((2, 100, 100))
119+
A[0, :, :] = a1
120+
A[1, :, :] = a2
121+
122+
# wasserstein
123+
reg = 1e-3
124+
bary_wass = ot.bregman.convolutional_barycenter2d(A, reg)
125+
126+
np.testing.assert_allclose(1, np.sum(bary_wass))
127+
128+
# help in checking if log and verbose do not bug the function
129+
ot.bregman.convolutional_barycenter2d(A, reg, log=True, verbose=True)
130+
131+
108132
def test_unmix():
109133

110134
n_bins = 50 # nb bins

0 commit comments

Comments
 (0)