Commits

Brian Kearns committed f14db74

give longfloat its own box so we can differentiate

  • Participants
  • Parent commits 1606b57

Comments (0)

Files changed (3)

File pypy/module/micronumpy/interp_boxes.py

 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 ()
     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):
     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),

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

             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
 

File pypy/module/micronumpy/types.py

     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):