MCPcopy Create free account
hub / github.com/PythonOT/POT / test_weak_ot

Function test_weak_ot

test/test_weak.py:11–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9
10
11def test_weak_ot():
12 # test weak ot solver and identity stationary point
13 n = 50
14 rng = np.random.RandomState(0)
15
16 xs = rng.randn(n, 2)
17 xt = rng.randn(n, 2)
18 u = ot.utils.unif(n)
19
20 G, log = ot.weak_optimal_transport(xs, xt, u, u, log=True)
21
22 # check constraints
23 np.testing.assert_allclose(u, G.sum(1))
24 np.testing.assert_allclose(u, G.sum(0))
25
26 # chaeck that identity is recovered
27 G = ot.weak_optimal_transport(xs, xs, G0=np.eye(n) / n)
28
29 # check G is identity
30 np.testing.assert_allclose(G, np.eye(n) / n)
31
32 # check constraints
33 np.testing.assert_allclose(u, G.sum(1))
34 np.testing.assert_allclose(u, G.sum(0))
35
36
37def test_weak_ot_bakends(nx):

Callers

nothing calls this directly

Calls 3

randnMethod · 0.45
sumMethod · 0.45
eyeMethod · 0.45

Tested by

no test coverage detected