Skip to content

Commit cd3ce61

Browse files
authored
[MRG] Cleanup test warnings (#242)
* remove warnings in tests from docstrings * working tets for bregman implemneted methods * pep8
1 parent 2a3f224 commit cd3ce61

File tree

7 files changed

+23
-23
lines changed

7 files changed

+23
-23
lines changed

ot/da.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
def sinkhorn_lpl1_mm(a, labels_a, b, M, reg, eta=0.1, numItermax=10,
2727
numInnerItermax=200, stopInnerThr=1e-9, verbose=False,
2828
log=False):
29-
"""
29+
r"""
3030
Solve the entropic regularization optimal transport problem with nonconvex
3131
group lasso regularization
3232
@@ -137,7 +137,7 @@ def sinkhorn_lpl1_mm(a, labels_a, b, M, reg, eta=0.1, numItermax=10,
137137
def sinkhorn_l1l2_gl(a, labels_a, b, M, reg, eta=0.1, numItermax=10,
138138
numInnerItermax=200, stopInnerThr=1e-9, verbose=False,
139139
log=False):
140-
"""
140+
r"""
141141
Solve the entropic regularization optimal transport problem with group
142142
lasso regularization
143143
@@ -245,7 +245,7 @@ def joint_OT_mapping_linear(xs, xt, mu=1, eta=0.001, bias=False, verbose=False,
245245
verbose2=False, numItermax=100, numInnerItermax=10,
246246
stopInnerThr=1e-6, stopThr=1e-5, log=False,
247247
**kwargs):
248-
"""Joint OT and linear mapping estimation as proposed in [8]
248+
r"""Joint OT and linear mapping estimation as proposed in [8]
249249
250250
The function solves the following optimization problem:
251251
@@ -434,7 +434,7 @@ def joint_OT_mapping_kernel(xs, xt, mu=1, eta=0.001, kerneltype='gaussian',
434434
numItermax=100, numInnerItermax=10,
435435
stopInnerThr=1e-6, stopThr=1e-5, log=False,
436436
**kwargs):
437-
"""Joint OT and nonlinear mapping estimation with kernels as proposed in [8]
437+
r"""Joint OT and nonlinear mapping estimation with kernels as proposed in [8]
438438
439439
The function solves the following optimization problem:
440440
@@ -645,7 +645,7 @@ def df(G):
645645

646646
def OT_mapping_linear(xs, xt, reg=1e-6, ws=None,
647647
wt=None, bias=True, log=False):
648-
""" return OT linear operator between samples
648+
r""" return OT linear operator between samples
649649
650650
The function estimates the optimal linear operator that aligns the two
651651
empirical distributions. This is equivalent to estimating the closed
@@ -1228,7 +1228,7 @@ def inverse_transform_labels(self, yt=None):
12281228

12291229

12301230
class LinearTransport(BaseTransport):
1231-
""" OT linear operator between empirical distributions
1231+
r""" OT linear operator between empirical distributions
12321232
12331233
The function estimates the optimal linear operator that aligns the two
12341234
empirical distributions. This is equivalent to estimating the closed

ot/dr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def proj(X):
109109

110110

111111
def wda(X, y, p=2, reg=1, k=10, solver=None, maxiter=100, verbose=0, P0=None):
112-
"""
112+
r"""
113113
Wasserstein Discriminant Analysis [11]_
114114
115115
The function solves the following optimization problem:

ot/gpu/bregman.py

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

1616
def sinkhorn_knopp(a, b, M, reg, numItermax=1000, stopThr=1e-9,
1717
verbose=False, log=False, to_numpy=True, **kwargs):
18-
"""
18+
r"""
1919
Solve the entropic regularization optimal transport on GPU
2020
2121
If the input matrix are in numpy format, they will be uploaded to the

ot/gromov.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
def init_matrix(C1, C2, p, q, loss_fun='square_loss'):
22-
"""Return loss matrices and tensors for Gromov-Wasserstein fast computation
22+
r"""Return loss matrices and tensors for Gromov-Wasserstein fast computation
2323
2424
Returns the value of \mathcal{L}(C1,C2) \otimes T with the selected loss
2525
function as the loss function of Gromow-Wasserstein discrepancy.
@@ -109,7 +109,7 @@ def h2(b):
109109

110110

111111
def tensor_product(constC, hC1, hC2, T):
112-
"""Return the tensor for Gromov-Wasserstein fast computation
112+
r"""Return the tensor for Gromov-Wasserstein fast computation
113113
114114
The tensor is computed as described in Proposition 1 Eq. (6) in [12].
115115
@@ -262,7 +262,7 @@ def update_kl_loss(p, lambdas, T, Cs):
262262

263263

264264
def gromov_wasserstein(C1, C2, p, q, loss_fun, log=False, armijo=False, **kwargs):
265-
"""
265+
r"""
266266
Returns the gromov-wasserstein transport between (C1,p) and (C2,q)
267267
268268
The function solves the following optimization problem:
@@ -343,7 +343,7 @@ def df(G):
343343

344344

345345
def gromov_wasserstein2(C1, C2, p, q, loss_fun, log=False, armijo=False, **kwargs):
346-
"""
346+
r"""
347347
Returns the gromov-wasserstein discrepancy between (C1,p) and (C2,q)
348348
349349
The function solves the following optimization problem:
@@ -420,7 +420,7 @@ def df(G):
420420

421421

422422
def fused_gromov_wasserstein(M, C1, C2, p, q, loss_fun='square_loss', alpha=0.5, armijo=False, log=False, **kwargs):
423-
"""
423+
r"""
424424
Computes the FGW transport between two graphs see [24]
425425
426426
.. math::
@@ -496,7 +496,7 @@ def df(G):
496496

497497

498498
def fused_gromov_wasserstein2(M, C1, C2, p, q, loss_fun='square_loss', alpha=0.5, armijo=False, log=False, **kwargs):
499-
"""
499+
r"""
500500
Computes the FGW distance between two graphs see [24]
501501
502502
.. math::
@@ -574,7 +574,7 @@ def df(G):
574574

575575
def entropic_gromov_wasserstein(C1, C2, p, q, loss_fun, epsilon,
576576
max_iter=1000, tol=1e-9, verbose=False, log=False):
577-
"""
577+
r"""
578578
Returns the gromov-wasserstein transport between (C1,p) and (C2,q)
579579
580580
(C1,p) and (C2,q)
@@ -681,7 +681,7 @@ def entropic_gromov_wasserstein(C1, C2, p, q, loss_fun, epsilon,
681681

682682
def entropic_gromov_wasserstein2(C1, C2, p, q, loss_fun, epsilon,
683683
max_iter=1000, tol=1e-9, verbose=False, log=False):
684-
"""
684+
r"""
685685
Returns the entropic gromov-wasserstein discrepancy between the two measured similarity matrices
686686
687687
(C1,p) and (C2,q)
@@ -747,7 +747,7 @@ def entropic_gromov_wasserstein2(C1, C2, p, q, loss_fun, epsilon,
747747

748748
def entropic_gromov_barycenters(N, Cs, ps, p, lambdas, loss_fun, epsilon,
749749
max_iter=1000, tol=1e-9, verbose=False, log=False, init_C=None):
750-
"""
750+
r"""
751751
Returns the gromov-wasserstein barycenters of S measured similarity matrices
752752
753753
(Cs)_{s=1}^{s=S}
@@ -857,7 +857,7 @@ def entropic_gromov_barycenters(N, Cs, ps, p, lambdas, loss_fun, epsilon,
857857

858858
def gromov_barycenters(N, Cs, ps, p, lambdas, loss_fun,
859859
max_iter=1000, tol=1e-9, verbose=False, log=False, init_C=None):
860-
"""
860+
r"""
861861
Returns the gromov-wasserstein barycenters of S measured similarity matrices
862862
863863
(Cs)_{s=1}^{s=S}

ot/lp/cvx.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def scipy_sparse_to_spmatrix(A):
2727

2828

2929
def barycenter(A, M, weights=None, verbose=False, log=False, solver='interior-point'):
30-
"""Compute the Wasserstein barycenter of distributions A
30+
r"""Compute the Wasserstein barycenter of distributions A
3131
3232
The function solves the following optimization problem [16]:
3333
@@ -76,7 +76,6 @@ def barycenter(A, M, weights=None, verbose=False, log=False, solver='interior-po
7676
.. [16] Agueh, M., & Carlier, G. (2011). Barycenters in the Wasserstein space. SIAM Journal on Mathematical Analysis, 43(2), 904-924.
7777
7878
79-
8079
"""
8180

8281
if weights is None:

ot/optim.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def solve_linesearch(cost, G, deltaG, Mi, f_val,
139139

140140
def cg(a, b, M, reg, f, df, G0=None, numItermax=200, numItermaxEmd=100000,
141141
stopThr=1e-9, stopThr2=1e-9, verbose=False, log=False, **kwargs):
142-
"""
142+
r"""
143143
Solve the general regularized OT problem with conditional gradient
144144
145145
The function solves the following optimization problem:
@@ -278,7 +278,7 @@ def cost(G):
278278

279279
def gcg(a, b, M, reg1, reg2, f, df, G0=None, numItermax=10,
280280
numInnerItermax=200, stopThr=1e-9, stopThr2=1e-9, verbose=False, log=False):
281-
"""
281+
r"""
282282
Solve the general regularized OT problem with the generalized conditional gradient
283283
284284
The function solves the following optimization problem:

test/test_bregman.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,9 @@ def test_implemented_methods():
321321
# make dists unbalanced
322322
b = ot.utils.unif(n)
323323
A = rng.rand(n, 2)
324+
A /= A.sum(0, keepdims=True)
324325
M = ot.dist(x, x)
325-
epsilon = 1.
326+
epsilon = 1.0
326327

327328
for method in IMPLEMENTED_METHODS:
328329
ot.bregman.sinkhorn(a, b, M, epsilon, method=method)

0 commit comments

Comments
 (0)