(nx, unbalanced_solver, divergence, eps)
| 879 | ), |
| 880 | ) |
| 881 | def test_alpha(nx, unbalanced_solver, divergence, eps): |
| 882 | n_samples = 5 # nb samples |
| 883 | |
| 884 | mu_s = np.array([0, 0]) |
| 885 | cov_s = np.array([[1, 0], [0, 1]]) |
| 886 | |
| 887 | xs = ot.datasets.make_2D_samples_gauss(n_samples, mu_s, cov_s, random_state=4) |
| 888 | xt = xs[::-1].copy() |
| 889 | |
| 890 | px_s, px_f = ot.unif(n_samples), ot.unif(2) |
| 891 | py_s, py_f = ot.unif(n_samples), ot.unif(2) |
| 892 | |
| 893 | xs_nx, xt_nx = nx.from_numpy(xs, xt) |
| 894 | px_s_nx, px_f_nx, py_s_nx, py_f_nx = nx.from_numpy(px_s, px_f, py_s, py_f) |
| 895 | |
| 896 | # linear part |
| 897 | M_samp = np.ones((n_samples, n_samples)) |
| 898 | np.fill_diagonal(np.fliplr(M_samp), 0) |
| 899 | M_feat = np.ones((2, 2)) |
| 900 | np.fill_diagonal(M_feat, 0) |
| 901 | M_samp_nx, M_feat_nx = nx.from_numpy(M_samp, M_feat) |
| 902 | |
| 903 | reg_m = (10, 5) |
| 904 | max_iter_ot = 5 |
| 905 | max_iter = 5 |
| 906 | tol = 1e-7 |
| 907 | tol_ot = 1e-7 |
| 908 | |
| 909 | alpha = 1 |
| 910 | full_list_alpha = [alpha, alpha] |
| 911 | full_tuple_alpha = (alpha, alpha) |
| 912 | tuple_alpha, list_alpha = (alpha), [alpha] |
| 913 | |
| 914 | list_options = [full_list_alpha, full_tuple_alpha, tuple_alpha, list_alpha] |
| 915 | |
| 916 | # test couplings |
| 917 | pi_sample, pi_feature = unbalanced_co_optimal_transport( |
| 918 | X=xs, |
| 919 | Y=xt, |
| 920 | wx_samp=px_s, |
| 921 | wx_feat=px_f, |
| 922 | wy_samp=py_s, |
| 923 | wy_feat=py_f, |
| 924 | reg_marginals=reg_m, |
| 925 | epsilon=eps, |
| 926 | divergence=divergence, |
| 927 | unbalanced_solver=unbalanced_solver, |
| 928 | alpha=alpha, |
| 929 | M_samp=M_samp, |
| 930 | M_feat=M_feat, |
| 931 | init_pi=None, |
| 932 | init_duals=None, |
| 933 | max_iter=max_iter, |
| 934 | tol=tol, |
| 935 | max_iter_ot=max_iter_ot, |
| 936 | tol_ot=tol_ot, |
| 937 | log=False, |
| 938 | verbose=False, |
nothing calls this directly
no test coverage detected