def test_random_x(self):
'''
Automatically generate a number of test cases for DFT() and compare results to numpy.fft.ftt
This will generate and test input lists of length 2 to max_N a total of 10 times each
'''
max_N=20
#for x of length 2 to max_N (inclusive)
for N in range(2,max_N+1):
#generate and test x ten times
for t in range(0,10):
#randomly generate x
x = []
for i in range(0,N):
x.append((random()-0.5)*2+(random()-0.5)*2j)
#test DFT by comparing to fft.fft out to 6 decimal places
testing.assert_array_almost_equal(DFT(x),fft.fft(x), err_msg='Your results do not agree with numpy.fft.fft',verbose=True)
#plot_rand(x)
评论列表
文章目录