w6_dft_test.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:EC602 作者: gottben 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号