(nx)
| 257 | |
| 258 | @pytest.skip_backend("tf") |
| 259 | def 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 | |
| 281 | def test_wasserstein_1d_unif_circle(): |
nothing calls this directly
no test coverage detected