From 8d288976d398749c5261daca22ee4d772bd5b489 Mon Sep 17 00:00:00 2001 From: RĂ©mi Flamary Date: Thu, 31 May 2018 11:08:01 +0200 Subject: add smooth.py + first tests --- test/test_smooth.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/test_smooth.py (limited to 'test/test_smooth.py') diff --git a/test/test_smooth.py b/test/test_smooth.py new file mode 100644 index 0000000..f951bf9 --- /dev/null +++ b/test/test_smooth.py @@ -0,0 +1,33 @@ +"""Tests for ot.smooth model """ + +# Author: Remi Flamary +# +# License: MIT License + +import warnings + +import numpy as np + +import ot +from ot.datasets import get_1D_gauss as gauss +import pytest + + +def test_smooth_ot_dual(): + # test sinkhorn + n = 100 + rng = np.random.RandomState(0) + + x = rng.randn(n, 2) + u = ot.utils.unif(n) + + M = ot.dist(x, x) + + G = ot.smooth.smooth_ot_dual(u, u, M, 1, stopThr=1e-10) + + # check constratints + np.testing.assert_allclose( + u, G.sum(1), atol=1e-05) # cf convergence sinkhorn + np.testing.assert_allclose( + u, G.sum(0), atol=1e-05) # cf convergence sinkhorn + \ No newline at end of file -- cgit v1.2.3