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

Function test_coot_raise_value_error

test/test_coot.py:168–207  ·  view source on GitHub ↗
(nx)

Source from the content-addressed store, hash-verified

166
167
168def test_coot_raise_value_error(nx):
169 n_samples = 80 # nb samples
170
171 mu_s = np.array([2, 4])
172 cov_s = np.array([[1, 0], [0, 1]])
173
174 xs = ot.datasets.make_2D_samples_gauss(n_samples, mu_s, cov_s, random_state=43)
175 xt = xs[::-1].copy()
176 xs_nx = nx.from_numpy(xs)
177 xt_nx = nx.from_numpy(xt)
178
179 # raise value error of method sinkhorn
180 def coot_sh(method_sinkhorn):
181 return coot(X=xs, Y=xt, method_sinkhorn=method_sinkhorn)
182
183 def coot_sh_nx(method_sinkhorn):
184 return coot(X=xs_nx, Y=xt_nx, method_sinkhorn=method_sinkhorn)
185
186 np.testing.assert_raises(ValueError, coot_sh, "not_sinkhorn")
187 np.testing.assert_raises(ValueError, coot_sh_nx, "not_sinkhorn")
188
189 # raise value error for epsilon
190 def coot_eps(epsilon):
191 return coot(X=xs, Y=xt, epsilon=epsilon)
192
193 def coot_eps_nx(epsilon):
194 return coot(X=xs_nx, Y=xt_nx, epsilon=epsilon)
195
196 np.testing.assert_raises(ValueError, coot_eps, (1, 2, 3))
197 np.testing.assert_raises(ValueError, coot_eps_nx, [1, 2, 3, 4])
198
199 # raise value error for alpha
200 def coot_alpha(alpha):
201 return coot(X=xs, Y=xt, alpha=alpha)
202
203 def coot_alpha_nx(alpha):
204 return coot(X=xs_nx, Y=xt_nx, alpha=alpha)
205
206 np.testing.assert_raises(ValueError, coot_alpha, [1])
207 np.testing.assert_raises(ValueError, coot_alpha_nx, np.arange(4))
208
209
210def test_coot_warmstart(nx):

Callers

nothing calls this directly

Calls 3

from_numpyMethod · 0.80
copyMethod · 0.45
arangeMethod · 0.45

Tested by

no test coverage detected