8000 Implement half dtype by mwiebe · Pull Request #16 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Implement half dtype #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Prev Previous commit
Next Next commit
ENH: core: Add half/float16 finfo support
  • Loading branch information
mwiebe committed Dec 2, 2010
commit 21c6094809969688231b676f879269021e579efd
4 changes: 4 additions & 0 deletions numpy/core/getlimits.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ def _init(self, dtype):
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)

Expand Down
8 changes: 7 additions & 1 deletion numpy/core/tests/test_getlimits.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

##################################################
Expand All @@ -15,6 +15,12 @@ def test_singleton(self):
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)
Expand Down
0