summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wiebe <mwwiebe@gmail.com>2010-11-09 15:42:31 -0800
committerCharles Harris <charlesr.harris@gmail.com>2010-12-01 20:02:15 -0700
commit82a5d0b8c08f315ee14ed4ec9cc4c25ca6dad595 (patch)
tree7372ee26f94e278c286d4b4f374cad6b07f389fe
parent88feef8f35cfb30795ed5c02031b69d99827b6f4 (diff)
downloadnumpy-82a5d0b8c08f315ee14ed4ec9cc4c25ca6dad595.tar.gz
ENH: core: Add half/float16 finfo support
-rw-r--r--numpy/core/getlimits.py4
-rw-r--r--numpy/core/tests/test_getlimits.py8
2 files changed, 11 insertions, 1 deletions
diff --git a/numpy/core/getlimits.py b/numpy/core/getlimits.py
index 4fa020e86..198862d6a 100644
--- a/numpy/core/getlimits.py
+++ b/numpy/core/getlimits.py
@@ -131,6 +131,10 @@ class finfo(object):
itype = ntypes.longlong
fmt = '%s'
precname = 'long double'
+ elif dtype is ntypes.half:
+ itype = ntypes.int16
+ fmt = '%12.5e'
+ precname = 'half'
else:
raise ValueError, repr(dtype)
diff --git a/numpy/core/tests/test_getlimits.py b/numpy/core/tests/test_getlimits.py
index f52463cbb..569dc0cc6 100644
--- a/numpy/core/tests/test_getlimits.py
+++ b/numpy/core/tests/test_getlimits.py
@@ -4,7 +4,7 @@
from numpy.testing import *
from numpy.core import finfo, iinfo
-from numpy import single,double,longdouble
+from numpy import half, single, double, longdouble
import numpy as np
##################################################
@@ -15,6 +15,12 @@ class TestPythonFloat(TestCase):
ftype2 = finfo(float)
assert_equal(id(ftype),id(ftype2))
+class TestHalf(TestCase):
+ def test_singleton(self):
+ ftype = finfo(half)
+ ftype2 = finfo(half)
+ assert_equal(id(ftype),id(ftype2))
+
class TestSingle(TestCase):
def test_singleton(self):
ftype = finfo(single)