2
# Copied from fftpack.helper by Pearu Peterson, October 2005
3
""" Test functions for fftpack.helper module
7
from numpy.testing import *
9
from numpy.dft import fftshift,ifftshift,fftfreq
17
class test_fftshift(ScipyTestCase):
19
def check_definition(self):
20
x = [0,1,2,3,4,-4,-3,-2,-1]
21
y = [-4,-3,-2,-1,0,1,2,3,4]
22
assert_array_almost_equal(fftshift(x),y)
23
assert_array_almost_equal(ifftshift(y),x)
24
x = [0,1,2,3,4,-5,-4,-3,-2,-1]
25
y = [-5,-4,-3,-2,-1,0,1,2,3,4]
26
assert_array_almost_equal(fftshift(x),y)
27
assert_array_almost_equal(ifftshift(y),x)
29
def check_inverse(self):
30
for n in [1,4,9,100,211]:
32
assert_array_almost_equal(ifftshift(fftshift(x)),x)
34
class test_fftfreq(ScipyTestCase):
36
def check_definition(self):
37
x = [0,1,2,3,4,-4,-3,-2,-1]
38
assert_array_almost_equal(9*fftfreq(9),x)
39
assert_array_almost_equal(9*pi*fftfreq(9,pi),x)
40
x = [0,1,2,3,4,-5,-4,-3,-2,-1]
41
assert_array_almost_equal(10*fftfreq(10),x)
42
assert_array_almost_equal(10*pi*fftfreq(10,pi),x)
44
if __name__ == "__main__":