~ubuntu-branches/ubuntu/karmic/python-scipy/karmic

« back to all changes in this revision

Viewing changes to Lib/signal/tests/test_signaltools.py

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T. Chen (new)
  • Date: 2005-03-16 02:15:29 UTC
  • Revision ID: james.westby@ubuntu.com-20050316021529-xrjlowsejs0cijig
Tags: upstream-0.3.2
ImportĀ upstreamĀ versionĀ 0.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#this program corresponds to special.py
 
2
import os
 
3
#import fpformat
 
4
import unittest
 
5
import sys
 
6
from unittest import TestCase
 
7
import scipy_base.limits as limits
 
8
from scipy_test.testing import *
 
9
set_package_path()
 
10
import scipy.signal as signal
 
11
del sys.path[0]
 
12
 
 
13
from Numeric import array
 
14
 
 
15
class test_convolve(TestCase):
 
16
    def check_basic(self):
 
17
        a = [3,4,5,6,5,4]
 
18
        b = [1,2,3]
 
19
        c = signal.convolve(a,b)
 
20
        assert_array_equal(c,array([3,10,22,28,32,32,23,12]))
 
21
 
 
22
class test_medfilt(TestCase):
 
23
    def check_basic(self):
 
24
        f = [[3,4,5],[2,3,4],[1,2,5]]
 
25
        d = signal.medfilt(f)
 
26
        assert_array_equal(d, [[0,3,0],[2,3,3],[0,2,0]])
 
27
 
 
28
class test_wiener(TestCase):
 
29
    def check_basic(self):
 
30
        g = array([[5,6,4,3],[3,5,6,2],[2,3,5,6],[1,6,9,7]],'d')
 
31
        correct = array([[2.16374269,3.2222222222, 2.8888888889, 1.6666666667],[2.666666667, 4.33333333333, 4.44444444444, 2.8888888888],[2.222222222, 4.4444444444, 5.4444444444, 4.801066874837],[1.33333333333, 3.92735042735, 6.0712560386, 5.0404040404]])
 
32
        h = signal.wiener(g)
 
33
        assert_array_almost_equal(h,correct,decimal=6)
 
34
 
 
35
if __name__ == "__main__":
 
36
    ScipyTest(signal).run()
 
37
 
 
38
 
 
39
 
 
40
 
 
41
 
 
42