From 0cb2b2efe901ed74c614046d250518769f870313 Mon Sep 17 00:00:00 2001 From: RĂ©mi Flamary Date: Fri, 29 Oct 2021 18:39:13 +0200 Subject: [MRG] Add tesing on wda (#296) --- test/test_dr.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) 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 @@ -60,6 +60,31 @@ def test_wda(): np.testing.assert_allclose(np.sum(Pwda**2, 0), np.ones(p)) +@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 -- cgit v1.2.3