Skip to content

Commit

Permalink
speedup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rflamary committed Sep 28, 2018
1 parent eaa05d1 commit 642fd5b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions test/test_bregman.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ def test_wasserstein_bary_2d():
a2 += a2.min()
a2 = a2 / np.sum(a2)
# creating matrix A containing all distributions
A = np.zeros((2, 100, 100))
A = np.zeros((2, size, size))
A[0, :, :] = a1
A[1, :, :] = a2

# wasserstein
reg = 1e-3
reg = 1e-2
bary_wass = ot.bregman.convolutional_barycenter2d(A, reg)

np.testing.assert_allclose(1, np.sum(bary_wass))
Expand Down
10 changes: 6 additions & 4 deletions test/test_gromov.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_gromov():
C1 /= C1.max()
C2 /= C2.max()

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

# check constratints
np.testing.assert_allclose(
Expand Down Expand Up @@ -69,7 +69,7 @@ def test_entropic_gromov():
C2 /= C2.max()

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

# check constratints
np.testing.assert_allclose(
Expand Down Expand Up @@ -107,7 +107,8 @@ def test_gromov_barycenter():
[ot.unif(ns), ot.unif(nt)
], ot.unif(n_samples), [.5, .5],
'square_loss', # 5e-4,
max_iter=100, tol=1e-3)
max_iter=100, tol=1e-3,
verbose=True)
np.testing.assert_allclose(Cb.shape, (n_samples, n_samples))

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

Cb2 = ot.gromov.entropic_gromov_barycenters(n_samples, [C1, C2],
Expand Down
12 changes: 6 additions & 6 deletions test/test_ot.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ def test_emd_empty():


def test_emd2_multi():
n = 1000 # nb bins
n = 500 # nb bins

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

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

ls = np.arange(20, 1000, 20)
ls = np.arange(20, 500, 20)
nb = len(ls)
b = np.zeros((n, nb))
for i in range(nb):
Expand Down Expand Up @@ -207,11 +207,11 @@ def test_warnings():


def test_dual_variables():
n = 5000 # nb bins
m = 6000 # nb bins
n = 500 # nb bins
m = 600 # nb bins

mean1 = 1000
mean2 = 1100
mean1 = 300
mean2 = 400

# bin positions
x = np.arange(n, dtype=np.float64)
Expand Down
2 changes: 1 addition & 1 deletion test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

def test_parmap():

n = 100
n = 10

def f(i):
return 1.0 * i * i
Expand Down

0 comments on commit 642fd5b

Please sign in to comment.