diff options
author | RĂ©mi Flamary <remi.flamary@gmail.com> | 2021-10-29 18:39:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-29 18:39:13 +0200 |
commit | 0cb2b2efe901ed74c614046d250518769f870313 (patch) | |
tree | f281da0a51cbea32863a0f9691d4df208d310332 /test | |
parent | 1b5c35b62980038960e1c1bdd15dce4b8cdd1e7e (diff) |
[MRG] Add tesing on wda (#296)
Diffstat (limited to 'test')
-rw-r--r-- | test/test_dr.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/test_dr.py b/test/test_dr.py index fa75a18..741f2ad 100644 --- a/test/test_dr.py +++ b/test/test_dr.py @@ -61,6 +61,31 @@ def test_wda(): @pytest.mark.skipif(nogo, reason="Missing modules (autograd or pymanopt)") +def test_wda_normalized(): + + n_samples = 100 # nb samples in source and target datasets + np.random.seed(0) + + # generate gaussian dataset + xs, ys = ot.datasets.make_data_classif('gaussrot', n_samples) + + n_features_noise = 8 + + xs = np.hstack((xs, np.random.randn(n_samples, n_features_noise))) + + p = 2 + + P0 = np.random.randn(10, p) + P0 /= P0.sum(0, keepdims=True) + + Pwda, projwda = ot.dr.wda(xs, ys, p, maxiter=10, P0=P0, normalize=True) + + projwda(xs) + + np.testing.assert_allclose(np.sum(Pwda**2, 0), np.ones(p)) + + +@pytest.mark.skipif(nogo, reason="Missing modules (autograd or pymanopt)") def test_prw(): d = 100 # Dimension n = 100 # Number samples |