Matti Picus avatar Matti Picus committed 500caf9

fixes for 96 bit long double, try to force 96 bit long double on windows

Comments (0)

Files changed (4)

pypy/module/micronumpy/interp_boxes.py

 
 # Is this the proper place for this?
 long_double_size = rffi.sizeof_c_type('long double', ignore_errors=True)
+import os
+if long_double_size == 8 and os.name == 'nt':
+    # this is a lie, or maybe a wish
+    long_double_size = 12
 
 
 def new_dtype_getter(name):

pypy/module/micronumpy/interp_dtype.py

                 w_box_type=space.gettypefor(interp_boxes.W_Float96Box),
                 aliases=["longfloat", "longdouble"],
             )
-            longdouble = self.w_float96dtype
+            self.w_longdouble = self.w_float96dtype
 
             self.w_complex192dtype = W_Dtype(
                 types.Complex192(),
                 alternate_constructors=[space.w_complex],
                 aliases=["clongdouble", "clongfloat"],
             )
-            clongdouble = self.w_complex192type
+            self.w_clongdouble = self.w_complex192dtype
 
         elif interp_boxes.long_double_size == 16:
             self.w_float128dtype = W_Dtype(
                 w_box_type=space.gettypefor(interp_boxes.W_Float128Box),
                 aliases=["longfloat", "longdouble"],
             )
-            longdouble = self.w_float128dtype
+            self.w_longdouble = self.w_float128dtype
 
             self.w_complex256dtype = W_Dtype(
                 types.Complex256(),
                 alternate_constructors=[space.w_complex],
                 aliases=["clongdouble", "clongfloat"],
             )
-            clongdouble = self.w_complex256dtype
+            self.w_clongdouble = self.w_complex256dtype
         else:
             self.w_float64dtype.aliases += ["longfloat", "longdouble"]
-            longdouble = self.w_float64dtype
-            clongdouble = self.w_complex64dtype
+            self.w_longdouble = self.w_float64dtype
+            self.w_clongdouble = self.w_complex64dtype
         self.w_stringdtype = W_Dtype(
             types.StringType(1),
             num=18,
             self.w_uint32dtype, self.w_longdtype, self.w_ulongdtype,
             self.w_int64dtype, self.w_uint64dtype,
             self.w_float16dtype, self.w_float32dtype, self.w_float64dtype,
-            longdouble,
-            self.w_complex64dtype, self.w_complex128dtype, clongdouble,
+            self.w_longdouble,
+            self.w_complex64dtype, self.w_complex128dtype, self.w_clongdouble,
             self.w_stringdtype, self.w_unicodedtype,
             self.w_voiddtype, self.w_intpdtype, self.w_uintpdtype,
         ]
         self.float_dtypes_by_num_bytes = sorted(
             (dtype.itemtype.get_element_size(), dtype)
             for dtype in [self.w_float16dtype, self.w_float32dtype,
-                          self.w_float64dtype, longdouble]
+                          self.w_float64dtype, self.w_longdouble]
         )
         self.dtypes_by_name = {}
         # we reverse, so the stuff with lower numbers override stuff with
             'LONGLONG': self.w_int64dtype,
             'SHORT': self.w_int16dtype,
             'VOID': self.w_voiddtype,
-            'LONGDOUBLE': longdouble,
+            'LONGDOUBLE': self.w_longdouble,
             'UBYTE': self.w_uint8dtype,
             'UINTP': self.w_ulongdtype,
             'ULONG': self.w_ulongdtype,
             'USHORT': self.w_uint16dtype,
             'FLOAT': self.w_float32dtype,
             'BOOL': self.w_booldtype,
-            'CLONGDOUBLE': clongdouble,
+            'CLONGDOUBLE': self.w_clongdouble,
         }
         typeinfo_partial = {
             'Generic': interp_boxes.W_GenericBox,

pypy/module/micronumpy/interp_ufuncs.py

         raise OperationError(space.w_TypeError, space.wrap("Unsupported types"))
     # Some operations promote op(bool, bool) to return int8, rather than bool
     if promote_bools and (dt1.kind == dt2.kind == interp_dtype.BOOLLTR):
+        print interp_dtype.get_dtype_cache(space).w_int8dtype
         return interp_dtype.get_dtype_cache(space).w_int8dtype
 
-    # Everything promotes to complex
+    # Everything numeric promotes to complex
     if dt2.is_complex_type() or dt1.is_complex_type():
-        if dt2.num == 14 and dt1.num == 14:
+        if dt2.num == 14:
             return interp_dtype.get_dtype_cache(space).w_complex64dtype
+        elif dt2.num == 15:
+            return interp_dtype.get_dtype_cache(space).w_complex128dtype
+        elif dt2.num == 16:
+            return interp_dtype.get_dtype_cache(space).w_clongdouble
         else:
-            return interp_dtype.get_dtype_cache(space).w_complex128dtype
+            raise OperationError(space.w_TypeError, space.wrap("Unsupported types"))
+
     
     if promote_to_float:
         return find_unaryop_result_dtype(space, dt2, promote_to_float=True)

pypy/module/micronumpy/types.py

         BoxType = interp_boxes.W_Float96Box
         format_code = "q"
 
+        def runpack_str(self, s):
+            assert len(s) == 12
+            fval = unpack_float128(s, native_is_bigendian)
+            return self.box(fval)
+
     class NonNativeFloat96(Float96):
         pass
 
         BoxType = interp_boxes.W_Complex192Box
         ComponentBoxType = interp_boxes.W_Float96Box
 
-
     NonNativeComplex192 = Complex192
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.