Skip to content

Commit

Permalink
improve unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ntessore committed Jul 28, 2022
1 parent 9e27220 commit 823b6bc
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions test_flt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 823b6bc

Please sign in to comment.