2
# Created by Pearu Peterson, September 2002
3
""" Test functions for fftpack.helper module
7
python setup_fftpack.py build
8
Run tests if scipy is installed:
9
python -c 'import scipy;scipy.fftpack.test(<level>)'
10
Run tests if fftpack is not installed:
11
python tests/test_helper.py [<level>]
15
from numpy.testing import *
17
from fftpack import fftshift,ifftshift,fftfreq,rfftfreq
25
class test_fftshift(NumpyTestCase):
27
def check_definition(self):
28
x = [0,1,2,3,4,-4,-3,-2,-1]
29
y = [-4,-3,-2,-1,0,1,2,3,4]
30
assert_array_almost_equal(fftshift(x),y)
31
assert_array_almost_equal(ifftshift(y),x)
32
x = [0,1,2,3,4,-5,-4,-3,-2,-1]
33
y = [-5,-4,-3,-2,-1,0,1,2,3,4]
34
assert_array_almost_equal(fftshift(x),y)
35
assert_array_almost_equal(ifftshift(y),x)
37
def check_inverse(self):
38
for n in [1,4,9,100,211]:
40
assert_array_almost_equal(ifftshift(fftshift(x)),x)
42
class test_fftfreq(NumpyTestCase):
44
def check_definition(self):
45
x = [0,1,2,3,4,-4,-3,-2,-1]
46
assert_array_almost_equal(9*fftfreq(9),x)
47
assert_array_almost_equal(9*pi*fftfreq(9,pi),x)
48
x = [0,1,2,3,4,-5,-4,-3,-2,-1]
49
assert_array_almost_equal(10*fftfreq(10),x)
50
assert_array_almost_equal(10*pi*fftfreq(10,pi),x)
52
class test_rfftfreq(NumpyTestCase):
54
def check_definition(self):
55
x = [0,1,1,2,2,3,3,4,4]
56
assert_array_almost_equal(9*rfftfreq(9),x)
57
assert_array_almost_equal(9*pi*rfftfreq(9,pi),x)
58
x = [0,1,1,2,2,3,3,4,4,5]
59
assert_array_almost_equal(10*rfftfreq(10),x)
60
assert_array_almost_equal(10*pi*rfftfreq(10,pi),x)
62
if __name__ == "__main__":