Complements :code:`test_emd_laplace_class` for uncovered options in :code:`emd_laplace`
(nx)
| 926 | @pytest.skip_backend("jax") |
| 927 | @pytest.skip_backend("tf") |
| 928 | def test_emd_laplace(nx): |
| 929 | """Complements :code:`test_emd_laplace_class` for uncovered options in :code:`emd_laplace`""" |
| 930 | ns = 50 |
| 931 | nt = 50 |
| 932 | |
| 933 | Xs, ys = make_data_classif("3gauss", ns) |
| 934 | Xt, yt = make_data_classif("3gauss2", nt) |
| 935 | |
| 936 | Xs, ys, Xt, yt = nx.from_numpy(Xs, ys, Xt, yt) |
| 937 | M = ot.dist(Xs, Xt) |
| 938 | with pytest.raises(ValueError): |
| 939 | ot.da.emd_laplace( |
| 940 | ot.unif(ns), ot.unif(nt), Xs, Xt, M, sim_param=["INVALID", "INPUT", 2] |
| 941 | ) |
| 942 | with pytest.raises(ValueError): |
| 943 | ot.da.emd_laplace( |
| 944 | ot.unif(ns), ot.unif(nt), Xs, Xt, M, sim=["INVALID", "INPUT", 2] |
| 945 | ) |
| 946 | |
| 947 | # test all margin constraints with gaussian similarity and disp regularisation |
| 948 | coupling = ot.da.emd_laplace( |
| 949 | ot.unif(ns, type_as=Xs), |
| 950 | ot.unif(nt, type_as=Xs), |
| 951 | Xs, |
| 952 | Xt, |
| 953 | M, |
| 954 | sim="gauss", |
| 955 | reg="disp", |
| 956 | ) |
| 957 | |
| 958 | assert_allclose( |
| 959 | nx.to_numpy(nx.sum(coupling, axis=0)), unif(nt), rtol=1e-3, atol=1e-3 |
| 960 | ) |
| 961 | assert_allclose( |
| 962 | nx.to_numpy(nx.sum(coupling, axis=1)), unif(ns), rtol=1e-3, atol=1e-3 |
| 963 | ) |
| 964 | |
| 965 | |
| 966 | @pytest.skip_backend("jax") |
nothing calls this directly
no test coverage detected