Author: Romain Guillebert <[email protected]>
Branch: numpy-pickle
Changeset: r64593:38aa177457d0
Date: 2013-05-27 22:26 +0200
http://bitbucket.org/pypy/pypy/changeset/38aa177457d0/
Log: Fix translation
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
@@ -35,7 +35,11 @@
def new(space, w_subtype, w_value):
dtype = _get_dtype(space)
return dtype.itemtype.coerce_subtype(space, w_subtype, w_value)
- return func_with_new_name(new, name + "_box_new"), staticmethod(_get_dtype)
+
+ def descr_reduce(self, space):
+ return self.reduce(space)
+
+ return func_with_new_name(new, name + "_box_new"),
staticmethod(_get_dtype), func_with_new_name(descr_reduce, "descr_reduce")
class PrimitiveBox(object):
@@ -50,7 +54,7 @@
def __repr__(self):
return '%s(%s)' % (self.__class__.__name__, self.value)
- def descr_reduce(self, space):
+ def reduce(self, space):
from rpython.rlib.rstring import StringBuilder
from rpython.rtyper.lltypesystem import rffi, lltype
@@ -60,14 +64,14 @@
assert isinstance(multiarray, MixedModule)
scalar = multiarray.get("scalar")
- value = lltype.malloc(rffi.CArray(lltype.typeOf(self.value)), 1, "raw")
+ value = lltype.malloc(rffi.CArray(lltype.typeOf(self.value)), 1,
flavor="raw")
value[0] = self.value
builder = StringBuilder()
builder.append_charpsize(rffi.cast(rffi.CCHARP, value),
rffi.sizeof(lltype.typeOf(self.value)))
ret = space.newtuple([scalar,
space.newtuple([space.wrap(self._get_dtype(space)),
space.wrap(builder.build())])])
- lltype.free(value, "raw")
+ lltype.free(value, flavor="raw")
return ret
class ComplexBox(object):
@@ -86,7 +90,7 @@
def convert_imag_to(self, dtype):
return dtype.box(self.imag)
- def descr_reduce(self, space):
+ def reduce(self, space):
from rpython.rlib.rstring import StringBuilder
from rpython.rtyper.lltypesystem import rffi, lltype
@@ -96,7 +100,7 @@
assert isinstance(multiarray, MixedModule)
scalar = multiarray.get("scalar")
- value = lltype.malloc(rffi.CArray(lltype.typeOf(self.real)), 2, "raw")
+ value = lltype.malloc(rffi.CArray(lltype.typeOf(self.real)), 2,
flavor="raw")
value[0] = self.real
value[1] = self.imag
@@ -104,7 +108,7 @@
builder.append_charpsize(rffi.cast(rffi.CCHARP, value),
rffi.sizeof(lltype.typeOf(self.real)) * 2)
ret = space.newtuple([scalar,
space.newtuple([space.wrap(self._get_dtype(space)),
space.wrap(builder.build())])])
- lltype.free(value, "raw")
+ lltype.free(value, flavor="raw")
return ret
class W_GenericBox(W_Root):
@@ -229,7 +233,7 @@
return convert_to_array(space, w_values)
class W_BoolBox(W_GenericBox, PrimitiveBox):
- descr__new__, _get_dtype = new_dtype_getter("bool")
+ descr__new__, _get_dtype, descr_reduce = new_dtype_getter("bool")
class W_NumberBox(W_GenericBox):
_attrs_ = ()
@@ -245,40 +249,40 @@
pass
class W_Int8Box(W_SignedIntegerBox, PrimitiveBox):
- descr__new__, _get_dtype = new_dtype_getter("int8")
+ descr__new__, _get_dtype, descr_reduce = new_dtype_getter("int8")
class W_UInt8Box(W_UnsignedIntegerBox, PrimitiveBox):
- descr__new__, _get_dtype = new_dtype_getter("uint8")
+ descr__new__, _get_dtype, descr_reduce = new_dtype_getter("uint8")
class W_Int16Box(W_SignedIntegerBox, PrimitiveBox):
- descr__new__, _get_dtype = new_dtype_getter("int16")
+ descr__new__, _get_dtype, descr_reduce = new_dtype_getter("int16")
class W_UInt16Box(W_UnsignedIntegerBox, PrimitiveBox):
- descr__new__, _get_dtype = new_dtype_getter("uint16")
+ descr__new__, _get_dtype, descr_reduce = new_dtype_getter("uint16")
class W_Int32Box(W_SignedIntegerBox, PrimitiveBox):
- descr__new__, _get_dtype = new_dtype_getter("int32")
+ descr__new__, _get_dtype, descr_reduce = new_dtype_getter("int32")
class W_UInt32Box(W_UnsignedIntegerBox, PrimitiveBox):
- descr__new__, _get_dtype = new_dtype_getter("uint32")
+ descr__new__, _get_dtype, descr_reduce = new_dtype_getter("uint32")
class W_LongBox(W_SignedIntegerBox, PrimitiveBox):
- descr__new__, _get_dtype = new_dtype_getter("long")
+ descr__new__, _get_dtype, descr_reduce = new_dtype_getter("long")
class W_ULongBox(W_UnsignedIntegerBox, PrimitiveBox):
- descr__new__, _get_dtype = new_dtype_getter("ulong")
+ descr__new__, _get_dtype, descr_reduce = new_dtype_getter("ulong")
class W_Int64Box(W_SignedIntegerBox, PrimitiveBox):
- descr__new__, _get_dtype = new_dtype_getter("int64")
+ descr__new__, _get_dtype, descr_reduce = new_dtype_getter("int64")
class W_LongLongBox(W_SignedIntegerBox, PrimitiveBox):
- descr__new__, _get_dtype = new_dtype_getter('longlong')
+ descr__new__, _get_dtype, descr_reduce = new_dtype_getter('longlong')
class W_UInt64Box(W_UnsignedIntegerBox, PrimitiveBox):
- descr__new__, _get_dtype = new_dtype_getter("uint64")
+ descr__new__, _get_dtype, descr_reduce = new_dtype_getter("uint64")
class W_ULongLongBox(W_SignedIntegerBox, PrimitiveBox):
- descr__new__, _get_dtype = new_dtype_getter('ulonglong')
+ descr__new__, _get_dtype, descr_reduce = new_dtype_getter('ulonglong')
class W_InexactBox(W_NumberBox):
_attrs_ = ()
@@ -287,13 +291,13 @@
_attrs_ = ()
class W_Float16Box(W_FloatingBox, PrimitiveBox):
- descr__new__, _get_dtype = new_dtype_getter("float16")
+ descr__new__, _get_dtype, descr_reduce = new_dtype_getter("float16")
class W_Float32Box(W_FloatingBox, PrimitiveBox):
- descr__new__, _get_dtype = new_dtype_getter("float32")
+ descr__new__, _get_dtype, descr_reduce = new_dtype_getter("float32")
class W_Float64Box(W_FloatingBox, PrimitiveBox):
- descr__new__, _get_dtype = new_dtype_getter("float64")
+ descr__new__, _get_dtype, descr_reduce = new_dtype_getter("float64")
class W_FlexibleBox(W_GenericBox):
def __init__(self, arr, ofs, dtype):
@@ -396,33 +400,33 @@
class W_Complex64Box(ComplexBox, W_ComplexFloatingBox):
- descr__new__, _get_dtype = new_dtype_getter("complex64")
+ descr__new__, _get_dtype, descr_reduce = new_dtype_getter("complex64")
_COMPONENTS_BOX = W_Float32Box
class W_Complex128Box(ComplexBox, W_ComplexFloatingBox):
- descr__new__, _get_dtype = new_dtype_getter("complex128")
+ descr__new__, _get_dtype, descr_reduce = new_dtype_getter("complex128")
_COMPONENTS_BOX = W_Float64Box
if ENABLED_LONG_DOUBLE and long_double_size == 12:
class W_Float96Box(W_FloatingBox, PrimitiveBox):
- descr__new__, _get_dtype = new_dtype_getter("float96")
+ descr__new__, _get_dtype, descr_reduce = new_dtype_getter("float96")
W_LongDoubleBox = W_Float96Box
class W_Complex192Box(ComplexBox, W_ComplexFloatingBox):
- descr__new__, _get_dtype = new_dtype_getter("complex192")
+ descr__new__, _get_dtype, descr_reduce = new_dtype_getter("complex192")
_COMPONENTS_BOX = W_Float96Box
W_CLongDoubleBox = W_Complex192Box
elif ENABLED_LONG_DOUBLE and long_double_size == 16:
class W_Float128Box(W_FloatingBox, PrimitiveBox):
- descr__new__, _get_dtype = new_dtype_getter("float128")
+ descr__new__, _get_dtype, descr_reduce = new_dtype_getter("float128")
W_LongDoubleBox = W_Float128Box
class W_Complex256Box(ComplexBox, W_ComplexFloatingBox):
- descr__new__, _get_dtype = new_dtype_getter("complex256")
+ descr__new__, _get_dtype, descr_reduce = new_dtype_getter("complex256")
_COMPONENTS_BOX = W_Float128Box
W_CLongDoubleBox = W_Complex256Box
diff --git a/pypy/module/micronumpy/interp_numarray.py
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -1058,7 +1058,7 @@
state = rffi.str2charp(space.str_w(w_state))
box = w_dtype.itemtype.box_raw_data(state)
- lltype.free(state, "raw")
+ lltype.free(state, flavor="raw")
return box
W_FlatIterator.typedef = TypeDef(
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit