1
""" Test functions for limits module.
4
from numpy.testing import *
7
from numpy.lib.getlimits import finfo, iinfo
8
from numpy import single,double,longdouble
11
##################################################
13
class TestPythonFloat(TestCase):
14
def test_singleton(self):
17
assert_equal(id(ftype),id(ftype2))
19
class TestSingle(TestCase):
20
def test_singleton(self):
22
ftype2 = finfo(single)
23
assert_equal(id(ftype),id(ftype2))
25
class TestDouble(TestCase):
26
def test_singleton(self):
28
ftype2 = finfo(double)
29
assert_equal(id(ftype),id(ftype2))
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))
37
class TestIinfo(TestCase):
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])
44
assert_equal(iinfo(dt1).min, iinfo(dt2).min)
45
assert_equal(iinfo(dt1).max, iinfo(dt2).max)
46
self.assertRaises(ValueError, iinfo, 'f4')
48
def test_unsigned_max(self):
49
types = np.sctypes['uint']
51
assert_equal(iinfo(T).max, T(-1))
58
if __name__ == "__main__":