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

Function test_partial_wasserstein_lagrange

test/test_partial.py:68–88  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

66
67
68def test_partial_wasserstein_lagrange():
69 n_samples = 20 # nb samples (gaussian)
70 n_noise = 20 # nb of samples (noise)
71
72 mu = np.array([0, 0])
73 cov = np.array([[1, 0], [0, 2]])
74
75 rng = np.random.RandomState(42)
76 xs = ot.datasets.make_2D_samples_gauss(n_samples, mu, cov, random_state=rng)
77 xs = np.append(xs, (rng.rand(n_noise, 2) + 1) * 4).reshape((-1, 2))
78 xt = ot.datasets.make_2D_samples_gauss(n_samples, mu, cov, random_state=rng)
79 xt = np.append(xt, (rng.rand(n_noise, 2) + 1) * -3).reshape((-1, 2))
80
81 M = ot.dist(xs, xt)
82
83 p = ot.unif(n_samples + n_noise)
84 q = ot.unif(n_samples + n_noise)
85
86 w0, log0 = ot.partial.partial_wasserstein_lagrange(p, q, M, 1, log=True)
87
88 w0, log0 = ot.partial.partial_wasserstein_lagrange(p, q, M, 100, log=True)
89
90
91def test_partial_wasserstein(nx):

Callers

nothing calls this directly

Calls 2

reshapeMethod · 0.45
randMethod · 0.45

Tested by

no test coverage detected