diff --git a/test_flt.py b/test_flt.py index 6347596..f67e6a8 100644 --- a/test_flt.py +++ b/test_flt.py @@ -4,27 +4,27 @@ from flt import dlt, idlt, theta -@pytest.mark.parametrize('n', [2, 5, 10, 11, 100, 101, 1000, 1001]) +@pytest.mark.parametrize('n', [1, 2, 5, 10, 11, 100, 101, 1000, 1001]) @pytest.mark.parametrize('closed', [False, True]) def test_dlt(n, closed): - t = theta(n, closed=closed) - for i in range(n): - a = np.zeros(n) - a[i] = 1 + if n == 1 and closed: + pytest.skip('closed FFT requires n > 1') - f = np.polynomial.legendre.legval(np.cos(t), a) + t = theta(n, closed=closed) + a = np.random.uniform(0, 1, size=n) + f = np.polynomial.legendre.legval(np.cos(t), a) - np.testing.assert_allclose(dlt(f, closed=closed), a, rtol=0, atol=1e-12) + np.testing.assert_allclose(dlt(f, closed=closed), a) -@pytest.mark.parametrize('n', [2, 5, 10, 11, 100, 101, 1000, 1001]) +@pytest.mark.parametrize('n', [1, 2, 5, 10, 11, 100, 101, 1000, 1001]) @pytest.mark.parametrize('closed', [False, True]) def test_idlt(n, closed): - t = theta(n, closed=closed) - for i in range(n): - a = np.zeros(n) - a[i] = 1 + if n == 1 and closed: + pytest.skip('closed FFT requires n > 1') - f = np.polynomial.legendre.legval(np.cos(t), a) + t = theta(n, closed=closed) + a = np.random.uniform(0, 1, size=n) + f = np.polynomial.legendre.legval(np.cos(t), a) - np.testing.assert_allclose(idlt(a, closed=closed), f, rtol=0, atol=1e-10) + np.testing.assert_allclose(idlt(a, closed=closed), f)