diff options
author | Travis Oliphant <oliphant@enthought.com> | 2007-12-15 18:54:52 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2007-12-15 18:54:52 +0000 |
commit | e76b5fa6896c09257181675bbf4cf47789d32927 (patch) | |
tree | 7174e22c68fc47df61e745ee18625ee9f4f5b88c /tests/test_getlimits.py | |
parent | 02ee35a7e1c722a1cdac8f3a60fe9ef7aa079a37 (diff) | |
download | numpy-e76b5fa6896c09257181675bbf4cf47789d32927.tar.gz |
Create a branch for io work in NumPy
Diffstat (limited to 'tests/test_getlimits.py')
-rw-r--r-- | tests/test_getlimits.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/test_getlimits.py b/tests/test_getlimits.py new file mode 100644 index 000000000..3c53f3322 --- /dev/null +++ b/tests/test_getlimits.py @@ -0,0 +1,55 @@ +""" Test functions for limits module. +""" + +from numpy.testing import * +set_package_path() +import numpy.lib;reload(numpy.lib) +from numpy.lib.getlimits import finfo, iinfo +from numpy import single,double,longdouble +import numpy as N +restore_path() + +################################################## + +class TestPythonFloat(NumpyTestCase): + def check_singleton(self): + ftype = finfo(float) + ftype2 = finfo(float) + assert_equal(id(ftype),id(ftype2)) + +class TestSingle(NumpyTestCase): + def check_singleton(self): + ftype = finfo(single) + ftype2 = finfo(single) + assert_equal(id(ftype),id(ftype2)) + +class TestDouble(NumpyTestCase): + def check_singleton(self): + ftype = finfo(double) + ftype2 = finfo(double) + assert_equal(id(ftype),id(ftype2)) + +class TestLongdouble(NumpyTestCase): + def check_singleton(self,level=2): + ftype = finfo(longdouble) + ftype2 = finfo(longdouble) + assert_equal(id(ftype),id(ftype2)) + +class TestIinfo(NumpyTestCase): + def check_basic(self): + dts = zip(['i1', 'i2', 'i4', 'i8', + 'u1', 'u2', 'u4', 'u8'], + [N.int8, N.int16, N.int32, N.int64, + N.uint8, N.uint16, N.uint32, N.uint64]) + for dt1, dt2 in dts: + assert_equal(iinfo(dt1).min, iinfo(dt2).min) + assert_equal(iinfo(dt1).max, iinfo(dt2).max) + self.assertRaises(ValueError, iinfo, 'f4') + + def check_unsigned_max(self): + types = N.sctypes['uint'] + for T in types: + assert_equal(iinfo(T).max, T(-1)) + +if __name__ == "__main__": + NumpyTest().run() |