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

« back to all changes in this revision

Viewing changes to Lib/maxentropy/tests/test_maxentropy.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
#!/usr/bin/env python
 
2
 
 
3
""" Test functions for maximum entropy module.
 
4
 
 
5
Author: Ed Schofield, 2003-2005
 
6
Copyright: Ed Schofield, 2003-2005
 
7
"""
 
8
 
 
9
import sys
 
10
from numpy.testing import *
 
11
from numpy import arange, add, array, dot, zeros, identity, log, exp, ones
 
12
set_package_path()
 
13
from scipy.maxentropy.maxentropy import *
 
14
restore_path()
 
15
 
 
16
import unittest
 
17
 
 
18
 
 
19
class test_maxentropy(ScipyTestCase):
 
20
    """Test whether logsumexp() function correctly handles large
 
21
    inputs.
 
22
    """
 
23
    def check_logsumexp(self, level=1):
 
24
        a = arange(200)
 
25
        desired = log(sum(exp(a)))
 
26
        assert_almost_equal(logsumexp(a), desired)
 
27
 
 
28
        # Now test with large numbers
 
29
        b = [1000,1000]
 
30
        desired = 1000.0 + log(2.0)
 
31
        assert_almost_equal(logsumexp(b), desired)
 
32
 
 
33
        n = 1000
 
34
        b = ones(n)*10000
 
35
        desired = 10000.0 + log(n)
 
36
        assert_almost_equal(logsumexp(b), desired)
 
37
 
 
38
    def check_simple(self, level=1):
 
39
        # Write me!
 
40
        pass
 
41
 
 
42
 
 
43
if __name__ == "__main__":
 
44
    ScipyTest().run()