Skip to content

Commit 642fd5b

Browse files
committed
speedup tests
1 parent eaa05d1 commit 642fd5b

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

test/test_bregman.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ def test_wasserstein_bary_2d():
118118
a2 += a2.min()
119119
a2 = a2 / np.sum(a2)
120120
# creating matrix A containing all distributions
121-
A = np.zeros((2, 100, 100))
121+
A = np.zeros((2, size, size))
122122
A[0, :, :] = a1
123123
A[1, :, :] = a2
124124

125125
# wasserstein
126-
reg = 1e-3
126+
reg = 1e-2
127127
bary_wass = ot.bregman.convolutional_barycenter2d(A, reg)
128128

129129
np.testing.assert_allclose(1, np.sum(bary_wass))

test/test_gromov.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_gromov():
2828
C1 /= C1.max()
2929
C2 /= C2.max()
3030

31-
G = ot.gromov.gromov_wasserstein(C1, C2, p, q, 'square_loss')
31+
G = ot.gromov.gromov_wasserstein(C1, C2, p, q, 'square_loss', verbose=True)
3232

3333
# check constratints
3434
np.testing.assert_allclose(
@@ -69,7 +69,7 @@ def test_entropic_gromov():
6969
C2 /= C2.max()
7070

7171
G = ot.gromov.entropic_gromov_wasserstein(
72-
C1, C2, p, q, 'square_loss', epsilon=5e-4)
72+
C1, C2, p, q, 'square_loss', epsilon=5e-4, verbose=True)
7373

7474
# check constratints
7575
np.testing.assert_allclose(
@@ -107,7 +107,8 @@ def test_gromov_barycenter():
107107
[ot.unif(ns), ot.unif(nt)
108108
], ot.unif(n_samples), [.5, .5],
109109
'square_loss', # 5e-4,
110-
max_iter=100, tol=1e-3)
110+
max_iter=100, tol=1e-3,
111+
verbose=True)
111112
np.testing.assert_allclose(Cb.shape, (n_samples, n_samples))
112113

113114
Cb2 = ot.gromov.gromov_barycenters(n_samples, [C1, C2],
@@ -134,7 +135,8 @@ def test_gromov_entropic_barycenter():
134135
[ot.unif(ns), ot.unif(nt)
135136
], ot.unif(n_samples), [.5, .5],
136137
'square_loss', 2e-3,
137-
max_iter=100, tol=1e-3)
138+
max_iter=100, tol=1e-3,
139+
verbose=True)
138140
np.testing.assert_allclose(Cb.shape, (n_samples, n_samples))
139141

140142
Cb2 = ot.gromov.entropic_gromov_barycenters(n_samples, [C1, C2],

test/test_ot.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ def test_emd_empty():
7070

7171

7272
def test_emd2_multi():
73-
n = 1000 # nb bins
73+
n = 500 # nb bins
7474

7575
# bin positions
7676
x = np.arange(n, dtype=np.float64)
7777

7878
# Gaussian distributions
7979
a = gauss(n, m=20, s=5) # m= mean, s= std
8080

81-
ls = np.arange(20, 1000, 20)
81+
ls = np.arange(20, 500, 20)
8282
nb = len(ls)
8383
b = np.zeros((n, nb))
8484
for i in range(nb):
@@ -207,11 +207,11 @@ def test_warnings():
207207

208208

209209
def test_dual_variables():
210-
n = 5000 # nb bins
211-
m = 6000 # nb bins
210+
n = 500 # nb bins
211+
m = 600 # nb bins
212212

213-
mean1 = 1000
214-
mean2 = 1100
213+
mean1 = 300
214+
mean2 = 400
215215

216216
# bin positions
217217
x = np.arange(n, dtype=np.float64)

test/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
def test_parmap():
1414

15-
n = 100
15+
n = 10
1616

1717
def f(i):
1818
return 1.0 * i * i

0 commit comments

Comments
 (0)