1. Pypy
  2. Untitled project
  3. pypy

Commits

mattip  committed bd6c027

add failing tests for float128 (64 bit linux)

  • Participants
  • Parent commits 76d0d34
  • Branches numpypy-longdouble

Comments (0)

Files changed (4)

File pypy/module/micronumpy/__init__.py

View file
 from pypy.interpreter.mixedmodule import MixedModule
+from pypy.module.micronumpy.interp_boxes import long_double_size
 
 
 class Module(MixedModule):
         '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'

File pypy/module/micronumpy/interp_dtype.py

View file
                 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

File pypy/module/micronumpy/test/test_numarray.py

View file
 
     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)
         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

File pypy/module/micronumpy/types.py

View file
         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_ = ()
         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