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

Function test_sliced_sphere_same_proj

test/test_sliced.py:329–350  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

327
328
329def 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
353def test_sliced_sphere_bad_shapes():

Callers

nothing calls this directly

Calls 4

randnMethod · 0.45
sqrtMethod · 0.45
sumMethod · 0.45
allcloseMethod · 0.45

Tested by

no test coverage detected