Author: mattip <[email protected]>
Branch: numpypy-longdouble
Changeset: r59584:500caf98376b
Date: 2012-12-27 01:50 +0200
http://bitbucket.org/pypy/pypy/changeset/500caf98376b/
Log: fixes for 96 bit long double, try to force 96 bit long double on
windows
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
@@ -17,6 +17,10 @@
# 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):
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
@@ -441,7 +441,7 @@
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(),
@@ -453,7 +453,7 @@
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(
@@ -465,7 +465,7 @@
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(),
@@ -477,11 +477,11 @@
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,
@@ -553,15 +553,15 @@
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
@@ -587,7 +587,7 @@
'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,
@@ -610,7 +610,7 @@
'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,
diff --git a/pypy/module/micronumpy/interp_ufuncs.py
b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -373,14 +373,20 @@
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)
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
@@ -1518,6 +1518,11 @@
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
@@ -1529,7 +1534,6 @@
BoxType = interp_boxes.W_Complex192Box
ComponentBoxType = interp_boxes.W_Float96Box
-
NonNativeComplex192 = Complex192
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit