[pypy-commit] pypy numpypy-complex2: fix for ztranslation
mattip
noreply at buildbot.pypy.org
Sat Aug 25 23:25:48 CEST 2012
Author: mattip <matti.picus at gmail.com>
Branch: numpypy-complex2
Changeset: r56855:00056348c32b
Date: 2012-08-25 22:36 +0300
http://bitbucket.org/pypy/pypy/changeset/00056348c32b/
Log: fix for ztranslation
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
@@ -41,15 +41,15 @@
self.real = real
self.imag = imag
- def descr_get_real(self, space):
- return space.wrap(self._COMPONENTS_BOX(self.real))
-
- def descr_get_imag(self, space):
- return space.wrap(self._COMPONENTS_BOX(self.imag))
-
def convert_to(self, dtype):
return dtype.box_complex(self.real, self.imag)
+ def convert_real_to(self, dtype):
+ return dtype.box(self.real)
+
+ def convert_imag_to(self, dtype):
+ return dtype.box(self.imag)
+
class W_GenericBox(Wrappable):
_attrs_ = ()
@@ -290,6 +290,18 @@
class W_ComplexFloatingBox(W_InexactBox):
_attrs_ = ()
+ def descr_get_real(self, space):
+ dtype = self._COMPONENTS_BOX._get_dtype(space)
+ box = self.convert_real_to(dtype)
+ assert isinstance(box, self._COMPONENTS_BOX)
+ return space.wrap(box.value)
+
+ def descr_get_imag(self, space):
+ dtype = self._COMPONENTS_BOX._get_dtype(space)
+ box = self.convert_imag_to(dtype)
+ assert isinstance(box, self._COMPONENTS_BOX)
+ return space.wrap(box.value)
+
class W_Complex64Box(ComplexBox, W_ComplexFloatingBox):
descr__new__, _get_dtype = new_dtype_getter("complex64")
_COMPONENTS_BOX = W_Float32Box
@@ -490,13 +502,13 @@
W_Complex128Box.typedef = TypeDef("complex128", (W_ComplexFloatingBox.typedef, complex_typedef),
__module__ = "numpypy",
__new__ = interp2app(W_Complex128Box.descr__new__.im_func),
- real = GetSetProperty(W_Complex128Box.descr_get_real),
- imag = GetSetProperty(W_Complex128Box.descr_get_imag),
+ real = GetSetProperty(W_ComplexFloatingBox.descr_get_real),
+ imag = GetSetProperty(W_ComplexFloatingBox.descr_get_imag),
)
W_Complex64Box.typedef = TypeDef("complex64", (W_ComplexFloatingBox.typedef),
__module__ = "numpypy",
__new__ = interp2app(W_Complex64Box.descr__new__.im_func),
- real = GetSetProperty(W_Complex64Box.descr_get_real),
- imag = GetSetProperty(W_Complex64Box.descr_get_imag),
+ real = GetSetProperty(W_ComplexFloatingBox.descr_get_real),
+ imag = GetSetProperty(W_ComplexFloatingBox.descr_get_imag),
)
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
@@ -974,7 +974,9 @@
def unbox(self, box):
assert isinstance(box, self.BoxType)
- return box.real, box.imag
+ # do this in two stages since real, imag are read only
+ real, imag = box.real, box.imag
+ return real, imag
def store(self, arr, i, offset, box):
real, imag = self.unbox(box)
More information about the pypy-commit
mailing list