-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_flt.py
30 lines (21 loc) · 881 Bytes
/
test_flt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import numpy as np
import pytest
from flt import dlt, idlt, theta
@pytest.mark.parametrize('n', [1, 2, 5, 10, 11, 100, 101, 1000, 1001])
@pytest.mark.parametrize('closed', [False, True])
def test_dlt(n, closed):
if n == 1 and closed:
pytest.skip('closed FFT requires n > 1')
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)
@pytest.mark.parametrize('n', [1, 2, 5, 10, 11, 100, 101, 1000, 1001])
@pytest.mark.parametrize('closed', [False, True])
def test_idlt(n, closed):
if n == 1 and closed:
pytest.skip('closed FFT requires n > 1')
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)