diff options
author | Stefan van der Walt <stefan@sun.ac.za> | 2007-05-13 17:36:19 +0000 |
---|---|---|
committer | Stefan van der Walt <stefan@sun.ac.za> | 2007-05-13 17:36:19 +0000 |
commit | 008ff0e9efab76d609315dba765f193760a8a8e7 (patch) | |
tree | f7a615a7b71c1a0af1e9dfd95a90a79277db3b82 /numpy/lib/tests/test_getlimits.py | |
parent | a34f98bdf24c7ae4b152ec9b472cb6442e6c00b7 (diff) | |
download | numpy-008ff0e9efab76d609315dba765f193760a8a8e7.tar.gz |
Add iinfo based on a patch by Albert Strasheim (ticket #250).
Diffstat (limited to 'numpy/lib/tests/test_getlimits.py')
-rw-r--r-- | numpy/lib/tests/test_getlimits.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_getlimits.py b/numpy/lib/tests/test_getlimits.py index 1eaadc953..7a4fea57a 100644 --- a/numpy/lib/tests/test_getlimits.py +++ b/numpy/lib/tests/test_getlimits.py @@ -4,8 +4,9 @@ from numpy.testing import * set_package_path() import numpy.lib;reload(numpy.lib) -from numpy.lib.getlimits import finfo +from numpy.lib.getlimits import finfo, iinfo from numpy import single,double,longdouble +import numpy as N restore_path() ################################################## @@ -34,5 +35,21 @@ class test_longdouble(NumpyTestCase): ftype2 = finfo(longdouble) assert_equal(id(ftype),id(ftype2)) +class test_iinfo(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() |