~ubuntu-branches/ubuntu/raring/python-scipy/raring-proposed

« back to all changes in this revision

Viewing changes to Lib/integrate/tests/test_quadrature.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-01-07 14:12:12 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070107141212-mm0ebkh5b37hcpzn
* Remove build dependency on python-numpy-dev.
* python-scipy: Depend on python-numpy instead of python-numpy-dev.
* Package builds on other archs than i386. Closes: #402783.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
import numpy
 
3
from numpy import cos, sin, pi
 
4
from numpy.testing import *
 
5
 
 
6
set_package_path()
 
7
from scipy.integrate import quadrature, romberg, romb
 
8
restore_path()
 
9
 
 
10
class test_quadrature(ScipyTestCase):
 
11
    def quad(self, x, a, b, args):
 
12
        raise NotImplementedError
 
13
 
 
14
    def check_quadrature(self):
 
15
        # Typical function with two extra arguments:
 
16
        def myfunc(x,n,z):       # Bessel function integrand
 
17
            return cos(n*x-z*sin(x))/pi
 
18
        val, err = quadrature(myfunc,0,pi,(2,1.8))
 
19
        table_val = 0.30614353532540296487
 
20
        assert_almost_equal(val, table_val, decimal=7)
 
21
 
 
22
    def check_romberg(self):
 
23
        # Typical function with two extra arguments:
 
24
        def myfunc(x, n, z):       # Bessel function integrand
 
25
            return cos(n*x-z*sin(x))/pi
 
26
        val = romberg(myfunc,0,pi, args=(2, 1.8))
 
27
        table_val = 0.30614353532540296487
 
28
        assert_almost_equal(val, table_val, decimal=7)
 
29
 
 
30
    def check_romb(self):
 
31
        assert_equal(romb(numpy.arange(17)),128)
 
32
 
 
33
if __name__ == "__main__":
 
34
    ScipyTest().run()