| 9 | |
| 10 | |
| 11 | def 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 | |
| 37 | def test_weak_ot_bakends(nx): |