Skip to content

Commit 7073e41

Browse files
author
Kilian Fatras
committed
remove if in test and cleaned code
1 parent 52134e9 commit 7073e41

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

examples/plot_stochastic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136
ot.plot.plot1D_mat(a, b, sinkhorn_pi, 'OT matrix Sinkhorn')
137137
pl.show()
138138

139+
139140
#############################################################################
140141
# COMPUTE TRANSPORTATION MATRIX FOR DUAL PROBLEM
141142
#############################################################################

ot/stochastic.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
##############################################################################
99
# Optimization toolbox for SEMI - DUAL problems
1010
##############################################################################
11+
12+
1113
def coordinate_grad_semi_dual(b, M, reg, beta, i):
1214
'''
1315
Compute the coordinate gradient update for regularized discrete

test/test_stochastic.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def test_stochastic_sag():
5757
# 2 identical discrete measures u defined on the same space with a
5858
# regularization term, a learning rate and a number of iteration
5959

60+
6061
def test_stochastic_asgd():
6162
# test asgd
6263
n = 15
@@ -134,9 +135,9 @@ def test_sag_asgd_sinkhorn():
134135
# 2 identical discrete measures u defined on the same space with a
135136
# regularization term, a batch_size and a number of iteration
136137

138+
137139
def test_stochastic_dual_sgd():
138140
# test sgd
139-
print("SGD")
140141
n = 10
141142
reg = 1
142143
numItermax = 300000
@@ -157,6 +158,7 @@ def test_stochastic_dual_sgd():
157158
np.testing.assert_allclose(
158159
u, G.sum(0), atol=1e-02) # cf convergence sgd
159160

161+
160162
#############################################################################
161163
#
162164
# TEST Convergence SGD toward Sinkhorn's solution
@@ -167,7 +169,6 @@ def test_stochastic_dual_sgd():
167169

168170
def test_dual_sgd_sinkhorn():
169171
# test all dual algorithms
170-
print("SGD vs Sinkhorn")
171172
n = 10
172173
reg = 1
173174
nb_iter = 300000
@@ -191,8 +192,3 @@ def test_dual_sgd_sinkhorn():
191192
zero, (G_sgd - G_sinkhorn).sum(0), atol=1e-02) # cf convergence sgd
192193
np.testing.assert_allclose(
193194
G_sgd, G_sinkhorn, atol=1e-02) # cf convergence sgd
194-
195-
196-
if __name__ == '__main__':
197-
test_stochastic_dual_sgd()
198-
test_dual_sgd_sinkhorn()

0 commit comments

Comments
 (0)