[pypy-commit] pypy default: give longfloat its own box so we can differentiate

bdkearns noreply at buildbot.pypy.org
Wed Oct 30 07:57:13 CET 2013


Author: Brian Kearns <bdkearns at gmail.com>
Branch: 
Changeset: r67727:f14db743ff68
Date: 2013-10-30 02:48 -0400
http://bitbucket.org/pypy/pypy/changeset/f14db743ff68/

Log:	give longfloat its own box so we can differentiate

diff --git a/pypy/module/micronumpy/interp_boxes.py b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -14,6 +14,7 @@
 from pypy.interpreter.mixedmodule import MixedModule
 from rpython.rtyper.lltypesystem import lltype
 from rpython.rlib.rstring import StringBuilder
+from pypy.module.micronumpy.constants import *
 
 
 MIXIN_32 = (int_typedef,) if LONG_BIT == 32 else ()
@@ -352,16 +353,12 @@
     descr__new__, _get_dtype, descr_reduce = new_dtype_getter("complex128")
     _COMPONENTS_BOX = W_Float64Box
 
-if long_double_size == 8:
-    W_FloatLongBox = W_Float64Box
-    W_ComplexLongBox = W_Complex128Box
-
-elif long_double_size in (12, 16):
+if long_double_size in (8, 12, 16):
     class W_FloatLongBox(W_FloatingBox, PrimitiveBox):
-        descr__new__, _get_dtype, descr_reduce = new_dtype_getter("float%d" % (long_double_size * 8))
+        descr__new__, _get_dtype, descr_reduce = new_dtype_getter(NPY_LONGDOUBLELTR)
 
     class W_ComplexLongBox(ComplexBox, W_ComplexFloatingBox):
-        descr__new__, _get_dtype, descr_reduce = new_dtype_getter("complex%d" % (long_double_size * 16))
+        descr__new__, _get_dtype, descr_reduce = new_dtype_getter(NPY_CLONGDOUBLELTR)
         _COMPONENTS_BOX = W_FloatLongBox
 
 class W_FlexibleBox(W_GenericBox):
@@ -651,7 +648,7 @@
     imag = GetSetProperty(W_ComplexFloatingBox.descr_get_imag),
 )
 
-if long_double_size in (12, 16):
+if long_double_size in (8, 12, 16):
     W_FloatLongBox.typedef = TypeDef("float%d" % (long_double_size * 8), (W_FloatingBox.typedef),
         __module__ = "numpypy",
         __new__ = interp2app(W_FloatLongBox.descr__new__.im_func),
diff --git a/pypy/module/micronumpy/test/test_dtypes.py b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -642,6 +642,11 @@
             assert numpy.intp is numpy.int64
             assert numpy.uintp is numpy.uint64
 
+        assert issubclass(numpy.float64, numpy.floating)
+        assert issubclass(numpy.longfloat, numpy.floating)
+        assert not issubclass(numpy.float64, numpy.longfloat)
+        assert not issubclass(numpy.longfloat, numpy.float64)
+
     def test_mro(self):
         import numpypy as numpy
 
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
@@ -1562,8 +1562,15 @@
     ComponentBoxType = interp_boxes.W_Float64Box
 
 if interp_boxes.long_double_size == 8:
-    FloatLong = Float64
-    ComplexLong = Complex128
+    class FloatLong(BaseType, Float):
+        T = rffi.DOUBLE
+        BoxType = interp_boxes.W_FloatLongBox
+        format_code = "d"
+
+    class ComplexLong(ComplexFloating, BaseType):
+        T = rffi.DOUBLE
+        BoxType = interp_boxes.W_ComplexLongBox
+        ComponentBoxType = interp_boxes.W_Float64Box
 
 elif interp_boxes.long_double_size in (12, 16):
     class FloatLong(BaseType, Float):


More information about the pypy-commit mailing list