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

Function test_solve_sample_methods

test/test_solvers.py:671–692  ·  view source on GitHub ↗
(nx, method_params)

Source from the content-addressed store, hash-verified

669
670@pytest.mark.parametrize("method_params", lst_method_params_solve_sample)
671def test_solve_sample_methods(nx, method_params):
672 n_samples_s = 10
673 n_samples_t = 9
674 n_features = 2
675 rng = np.random.RandomState(42)
676
677 x = rng.randn(n_samples_s, n_features)
678 y = rng.randn(n_samples_t, n_features)
679 a = ot.utils.unif(n_samples_s)
680 b = ot.utils.unif(n_samples_t)
681
682 xb, yb, ab, bb = nx.from_numpy(x, y, a, b)
683
684 sol = ot.solve_sample(x, y, **method_params)
685 solb = ot.solve_sample(xb, yb, ab, bb, **method_params)
686
687 # check some attributes (no need )
688 assert_allclose_sol(sol, solb)
689
690 sol2 = ot.solve_sample(x, x, **method_params)
691 if method_params["method"] not in ["factored", "lowrank", "nystroem"]:
692 np.testing.assert_allclose(sol2.value, 0, atol=1e-10)
693
694
695@pytest.mark.parametrize("method_params", lst_parameters_solve_sample_NotImplemented)

Callers

nothing calls this directly

Calls 3

assert_allclose_solFunction · 0.85
from_numpyMethod · 0.80
randnMethod · 0.45

Tested by

no test coverage detected