~jtaylor/ubuntu/precise/python-numpy/multiarch-fix-818867

« back to all changes in this revision

Viewing changes to numpy/lib/tests/test_getlimits.py

  • Committer: Bazaar Package Importer
  • Author(s): Sandro Tosi
  • Date: 2010-10-07 10:19:13 UTC
  • mfrom: (7.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20101007101913-8b1kmt8ho4upcl9s
Tags: 1:1.4.1-5
* debian/patches/10_use_local_python.org_object.inv_sphinx.diff
  - fixed small typo in description
* debian/patches/changeset_r8364.diff
  - fix memory corruption (double free); thanks to Joseph Barillari for the
    report and to Michael Gilbert for pushing resolution; Closes: #581058

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
""" Test functions for limits module.
2
 
"""
3
 
 
4
 
from numpy.testing import *
5
 
import numpy.lib
6
 
reload(numpy.lib)
7
 
from numpy.lib.getlimits import finfo, iinfo
8
 
from numpy import single,double,longdouble
9
 
import numpy as np
10
 
 
11
 
##################################################
12
 
 
13
 
class TestPythonFloat(TestCase):
14
 
    def test_singleton(self):
15
 
        ftype = finfo(float)
16
 
        ftype2 = finfo(float)
17
 
        assert_equal(id(ftype),id(ftype2))
18
 
 
19
 
class TestSingle(TestCase):
20
 
    def test_singleton(self):
21
 
        ftype = finfo(single)
22
 
        ftype2 = finfo(single)
23
 
        assert_equal(id(ftype),id(ftype2))
24
 
 
25
 
class TestDouble(TestCase):
26
 
    def test_singleton(self):
27
 
        ftype = finfo(double)
28
 
        ftype2 = finfo(double)
29
 
        assert_equal(id(ftype),id(ftype2))
30
 
 
31
 
class TestLongdouble(TestCase):
32
 
    def test_singleton(self,level=2):
33
 
        ftype = finfo(longdouble)
34
 
        ftype2 = finfo(longdouble)
35
 
        assert_equal(id(ftype),id(ftype2))
36
 
 
37
 
class TestIinfo(TestCase):
38
 
    def test_basic(self):
39
 
        dts = zip(['i1', 'i2', 'i4', 'i8',
40
 
                   'u1', 'u2', 'u4', 'u8'],
41
 
                  [np.int8, np.int16, np.int32, np.int64,
42
 
                   np.uint8, np.uint16, np.uint32, np.uint64])
43
 
        for dt1, dt2 in dts:
44
 
            assert_equal(iinfo(dt1).min, iinfo(dt2).min)
45
 
            assert_equal(iinfo(dt1).max, iinfo(dt2).max)
46
 
        self.assertRaises(ValueError, iinfo, 'f4')
47
 
 
48
 
    def test_unsigned_max(self):
49
 
        types = np.sctypes['uint']
50
 
        for T in types:
51
 
            assert_equal(iinfo(T).max, T(-1))
52
 
 
53
 
 
54
 
def test_instances():
55
 
    iinfo(10)
56
 
    finfo(3.0)
57
 
 
58
 
if __name__ == "__main__":
59
 
    run_module_suite()