Author: mattip
Branch: numpypy-longdouble
Changeset: r59409:bd6c0279e8fb
Date: 2012-12-12 13:50 -0800
http://bitbucket.org/pypy/pypy/changeset/bd6c0279e8fb/
Log:add failing tests for float128 (64 bit linux)
diff --git a/pypy/module/micronumpy/__init__.py
b/pypy/module/micronumpy/__init__.py
--- a/pypy/module/micronumpy/__init__.py
+++ b/pypy/module/micronumpy/__init__.py
@@ -1,4 +1,5 @@
from pypy.interpreter.mixedmodule import MixedModule
+from pypy.module.micronumpy.interp_boxes import long_double_size
class Module(MixedModule):
@@ -165,3 +166,8 @@
'max': 'app_numpy.max',
'arange': 'app_numpy.arange',
}
+
+if long_double_size == 16:
+Module.interpleveldefs['float128'] = 'interp_boxes.W_Float128Box'
+elif long_double_size == 12:
+Module.interpleveldefs['float96'] = 'interp_boxes.W_Float96Box'
diff --git a/pypy/module/micronumpy/interp_dtype.py
b/pypy/module/micronumpy/interp_dtype.py
--- a/pypy/module/micronumpy/interp_dtype.py
+++ b/pypy/module/micronumpy/interp_dtype.py
@@ -430,7 +430,7 @@
kind=FLOATINGLTR,
name="float128",
char="g",
-w_box_type=space.gettypefor(interp_boxes.W_Floati128Box),
+w_box_type=space.gettypefor(interp_boxes.W_Float128Box),
aliases=["longfloat", "longdouble"],
)
longdouble = self.w_float128dtype
diff --git a/pypy/module/micronumpy/test/test_numarray.py
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -2110,7 +2110,7 @@
def test_fromstring_types(self):
from _numpypy import (fromstring, int8, int16, int32, int64, uint8,
-uint16, uint32, float16, float32, float64)
+uint16, uint32, float16, float32, float64, longfloat, array)
a = fromstring('\xFF', dtype=int8)
assert a[0] == -1
b = fromstring('\xFF', dtype=uint8)
@@ -2133,12 +2133,18 @@
assert j[0] == 12
k = fromstring(self.float16val, dtype=float16)
assert k[0] == float16(5.)
-try:
+dt = array([5],dtype=longfloat).dtype
+if dt.itemsize == 12:
from _numpypy import float96
-except:
-skip('no float96 on this platform/compiler, maybe try float128?')
-k = fromstring('\x00\x00\x00\x00\x00\x00\x00\xa0\x01@\x00\x00',
dtype=float96)
-assert k[0] == float96(5.)
+m = fromstring('\x00\x00\x00\x00\x00\x00\x00\xa0\x01@\x00\x00',
dtype=float96)
+elif dt.itemsize==16:
+from _numpypy import float128
+m =
fromstring('\x00\x00\x00\x00\x00\x00\x00\xa0\x01@\x9c\xd3#\x7f\x00\x00',
dtype=float128)
+elif dt.itemsize == 8:
+skip('longfloat is float64')
+else:
+skip('unknown itemsize for longfloat')
+assert m[0] == longfloat(5.)
def test_fromstring_invalid(self):
from _numpypy import fromstring, uint16, uint8, int32
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -989,12 +989,10 @@
BoxType = interp_boxes.W_Float96Box
format_code = "q"
-class NonNativeFloat96(BaseType, NonNativeFloat):
-_attrs_ = ()
+class NonNativeFloat96(Float96):
+pass
-T = rffi.LONGDOUBLE
-BoxType = interp_boxes.W_Float96Box
-format_code = "q"
+
elif interp_boxes.long_double_size == 16:
class Float128(BaseType, Float):
_attrs_ = ()
@@ -1003,12 +1001,14 @@
BoxType = interp_boxes.W_Float128Box
format_code = "q"
-class NonNativeFloat128(BaseType, NonNativeFloat):
-_attrs_ = ()
+def runpack_str(self, s):
+assert len(s) == 16
+fval = unpack_float(s, native_is_bigendian)
+return self.box(fval)
-T = rffi.LONGDOUBLE
-BoxType = interp_boxes.W_Float128Box
-format_code = "q"
+class NonNativeFloat128(Float128):
+pass
+
class ComplexFloating(object):
_mixin_ = True
___
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit