~ubuntu-branches/ubuntu/feisty/python-numpy/feisty

« back to all changes in this revision

Viewing changes to numpy/dft/tests/test_helper.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-07-12 10:00:24 UTC
  • Revision ID: james.westby@ubuntu.com-20060712100024-5lw9q2yczlisqcrt
Tags: upstream-0.9.8
ImportĀ upstreamĀ versionĀ 0.9.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# Copied from fftpack.helper by Pearu Peterson, October 2005
 
3
""" Test functions for fftpack.helper module
 
4
"""
 
5
 
 
6
import sys
 
7
from numpy.testing import *
 
8
set_package_path()
 
9
from numpy.dft import fftshift,ifftshift,fftfreq
 
10
del sys.path[0]
 
11
 
 
12
from numpy import pi
 
13
 
 
14
def random(size):
 
15
    return rand(*size)
 
16
 
 
17
class test_fftshift(ScipyTestCase):
 
18
 
 
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)
 
28
 
 
29
    def check_inverse(self):
 
30
        for n in [1,4,9,100,211]:
 
31
            x = random((n,))
 
32
            assert_array_almost_equal(ifftshift(fftshift(x)),x)
 
33
 
 
34
class test_fftfreq(ScipyTestCase):
 
35
 
 
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)
 
43
 
 
44
if __name__ == "__main__":
 
45
    ScipyTest().run()