| 327 | |
| 328 | |
| 329 | def test_sliced_sphere_same_proj(): |
| 330 | n_projections = 10 |
| 331 | n = 100 |
| 332 | rng = np.random.RandomState(0) |
| 333 | |
| 334 | x = rng.randn(n, 3) |
| 335 | x = x / np.sqrt(np.sum(x**2, -1, keepdims=True)) |
| 336 | |
| 337 | y = rng.randn(n, 3) |
| 338 | y = y / np.sqrt(np.sum(y**2, -1, keepdims=True)) |
| 339 | |
| 340 | seed = 42 |
| 341 | |
| 342 | cost1, log1 = ot.sliced_wasserstein_sphere( |
| 343 | x, y, seed=seed, n_projections=n_projections, log=True |
| 344 | ) |
| 345 | cost2, log2 = ot.sliced_wasserstein_sphere( |
| 346 | x, y, seed=seed, n_projections=n_projections, log=True |
| 347 | ) |
| 348 | |
| 349 | assert np.allclose(log1["projections"], log2["projections"]) |
| 350 | assert np.isclose(cost1, cost2) |
| 351 | |
| 352 | |
| 353 | def test_sliced_sphere_bad_shapes(): |