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

Function test_init_plans

test/test_ucoot.py:165–293  ·  view source on GitHub ↗
(nx, unbalanced_solver, divergence, eps)

Source from the content-addressed store, hash-verified

163 ),
164)
165def test_init_plans(nx, unbalanced_solver, divergence, eps):
166 n_samples = 5 # nb samples
167
168 mu_s = np.array([0, 0])
169 cov_s = np.array([[1, 0], [0, 1]])
170
171 xs = ot.datasets.make_2D_samples_gauss(n_samples, mu_s, cov_s, random_state=4)
172 xt = xs[::-1].copy()
173
174 px_s, px_f = ot.unif(n_samples), ot.unif(2)
175 py_s, py_f = ot.unif(n_samples), ot.unif(2)
176 G0_samp = px_s[:, None] * py_s[None, :]
177 G0_feat = px_f[:, None] * py_f[None, :]
178
179 xs_nx, xt_nx, G0_samp_nx, G0_feat_nx = nx.from_numpy(xs, xt, G0_samp, G0_feat)
180 px_s_nx, px_f_nx, py_s_nx, py_f_nx = nx.from_numpy(px_s, px_f, py_s, py_f)
181
182 reg_m = (1, 5)
183 alpha = (0.1, 0.2)
184 max_iter_ot = 5
185 max_iter = 5
186 tol = 1e-7
187 tol_ot = 1e-7
188
189 # test couplings
190 pi_sample, pi_feature = unbalanced_co_optimal_transport(
191 X=xs,
192 Y=xt,
193 wx_samp=px_s,
194 wx_feat=px_f,
195 wy_samp=py_s,
196 wy_feat=py_f,
197 reg_marginals=reg_m,
198 epsilon=eps,
199 divergence=divergence,
200 unbalanced_solver=unbalanced_solver,
201 alpha=alpha,
202 M_samp=None,
203 M_feat=None,
204 init_pi=None,
205 init_duals=None,
206 max_iter=max_iter,
207 tol=tol,
208 max_iter_ot=max_iter_ot,
209 tol_ot=tol_ot,
210 log=False,
211 verbose=False,
212 )
213
214 pi_sample_nx, pi_feature_nx = unbalanced_co_optimal_transport(
215 X=xs_nx,
216 Y=xt_nx,
217 wx_samp=px_s_nx,
218 wx_feat=px_f_nx,
219 wy_samp=py_s_nx,
220 wy_feat=py_f_nx,
221 reg_marginals=reg_m,
222 epsilon=eps,

Callers

nothing calls this directly

Calls 5

from_numpyMethod · 0.80
to_numpyMethod · 0.80
copyMethod · 0.45

Tested by

no test coverage detected