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

Function test_wasserstein1d_circle_devices

test/test_1d_solver.py:259–278  ·  view source on GitHub ↗
(nx)

Source from the content-addressed store, hash-verified

257
258@pytest.skip_backend("tf")
259def test_wasserstein1d_circle_devices(nx):
260 rng = np.random.RandomState(0)
261
262 n = 10
263 x = np.linspace(0, 1, n)
264 rho_u = np.abs(rng.randn(n))
265 rho_u /= rho_u.sum()
266 rho_v = np.abs(rng.randn(n))
267 rho_v /= rho_v.sum()
268
269 for tp in nx.__type_list__:
270 print(nx.dtype_device(tp))
271
272 xb, rho_ub, rho_vb = nx.from_numpy(x, rho_u, rho_v, type_as=tp)
273
274 w1 = ot.wasserstein_circle(xb, xb, rho_ub, rho_vb, p=1)
275 w2_bsc = ot.wasserstein_circle(xb, xb, rho_ub, rho_vb, p=2)
276
277 nx.assert_same_dtype_device(xb, w1)
278 nx.assert_same_dtype_device(xb, w2_bsc)
279
280
281def test_wasserstein_1d_unif_circle():

Callers

nothing calls this directly

Calls 7

from_numpyMethod · 0.80
linspaceMethod · 0.45
absMethod · 0.45
randnMethod · 0.45
sumMethod · 0.45
dtype_deviceMethod · 0.45

Tested by

no test coverage detected