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

Function test_solve_sample_lazy

test/test_solvers.py:578–601  ·  view source on GitHub ↗
(nx)

Source from the content-addressed store, hash-verified

576
577
578def test_solve_sample_lazy(nx):
579 # test solve_sample when is_Lazy = False
580 n = 20
581 X_s = np.reshape(1.0 * np.arange(n), (n, 1))
582 X_t = np.reshape(1.0 * np.arange(0, n), (n, 1))
583
584 a = ot.utils.unif(X_s.shape[0])
585 b = ot.utils.unif(X_t.shape[0])
586
587 X_s, X_t, a, b = nx.from_numpy(X_s, X_t, a, b)
588
589 M = ot.dist(X_s, X_t)
590
591 # solve with ot.solve
592 sol00 = ot.solve(M, a, b, reg=1)
593
594 sol0 = ot.solve_sample(X_s, X_t, a, b, reg=1)
595
596 # solve signe weights
597 sol = ot.solve_sample(X_s, X_t, a, b, reg=1, lazy=True)
598
599 assert_allclose_sol(sol0, sol00)
600
601 np.testing.assert_allclose(sol0.plan, sol.lazy_plan[:], rtol=1e-5, atol=1e-5)
602
603
604@pytest.mark.skipif(sys.version_info < (3, 10), reason="requires python3.10 or higher")

Callers

nothing calls this directly

Calls 5

assert_allclose_solFunction · 0.85
from_numpyMethod · 0.80
reshapeMethod · 0.45
arangeMethod · 0.45
solveMethod · 0.45

Tested by

no test coverage detected