File: test_fdf.py

package info (click to toggle)
python-scipy 0.5.2-0.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 33,888 kB
  • ctags: 44,231
  • sloc: ansic: 156,256; cpp: 90,347; python: 89,604; fortran: 73,083; sh: 1,318; objc: 424; makefile: 342
file content (33 lines) | stat: -rw-r--r-- 1,054 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33


from numpy.testing import *
set_package_path()
from fdfpack import periodic_finite_difference as diff
restore_path()

from numpy import arange, add, array,sin,cos,pi

class test_diff(NumpyTestCase):
    def check_1(self):
        for n in [64,100,125,4000]:
            x = arange(n)*2*pi/n
            for m in range(5,15):
                assert_array_almost_equal(diff(sin(x),m=m),cos(x))
    def check_2(self):
        for n in [64,100,125,4000]:
            x = arange(n)*2*pi/n
            for m in range(8,15)+[6]:
                assert_array_almost_equal(diff(sin(x),k=2,m=m),-sin(x))
    def check_3(self):
        for n in [64,100,125,4000]:
            x = arange(n)*2*pi/n
            for m in range(7,15):
                assert_array_almost_equal(diff(sin(x),k=3,m=m)/n,-cos(x)/n)
    def check_4(self):
        for n in [64,100,125,200,2000]:
            x = arange(n)*2*pi/n
            for m in range(10,15):
                assert_array_almost_equal(diff(sin(x),k=4,m=m)/n,sin(x)/n)

if __name__ == "__main__":
    NumpyTest().run()