[pypy-commit] pypy numpypy-complex2: try to fix translation, seems to need wrap__r_single_float

mattip noreply at buildbot.pypy.org
Sat Aug 25 23:25:50 CEST 2012


Author: mattip <matti.picus at gmail.com>
Branch: numpypy-complex2
Changeset: r56856:657c42eb09a4
Date: 2012-08-26 00:25 +0300
http://bitbucket.org/pypy/pypy/changeset/657c42eb09a4/

Log:	try to fix translation, seems to need wrap__r_single_float

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
@@ -290,6 +290,10 @@
 class W_ComplexFloatingBox(W_InexactBox):
     _attrs_ = ()
 
+class W_Complex64Box(ComplexBox, W_ComplexFloatingBox):
+    descr__new__, _get_dtype = new_dtype_getter("complex64")
+    _COMPONENTS_BOX = W_Float64Box
+
     def descr_get_real(self, space):
         dtype = self._COMPONENTS_BOX._get_dtype(space)
         box = self.convert_real_to(dtype)
@@ -302,13 +306,21 @@
         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")
+class W_Complex128Box(ComplexBox, W_ComplexFloatingBox):
+    descr__new__, _get_dtype = new_dtype_getter("complex128")
     _COMPONENTS_BOX = W_Float32Box
 
-class W_Complex128Box(ComplexBox, W_ComplexFloatingBox):
-    descr__new__, _get_dtype = new_dtype_getter("complex128")
-    _COMPONENTS_BOX = W_Float64Box
+    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)
 
     
 
@@ -502,13 +514,13 @@
 W_Complex128Box.typedef = TypeDef("complex128", (W_ComplexFloatingBox.typedef, complex_typedef),
     __module__ = "numpypy",
     __new__ = interp2app(W_Complex128Box.descr__new__.im_func),
-    real = GetSetProperty(W_ComplexFloatingBox.descr_get_real),
-    imag = GetSetProperty(W_ComplexFloatingBox.descr_get_imag),
+    real = GetSetProperty(W_Complex128Box.descr_get_real),
+    imag = GetSetProperty(W_Complex128Box.descr_get_imag),
 )
 
 W_Complex64Box.typedef = TypeDef("complex64", (W_ComplexFloatingBox.typedef),
     __module__ = "numpypy",
     __new__ = interp2app(W_Complex64Box.descr__new__.im_func),
-    real = GetSetProperty(W_ComplexFloatingBox.descr_get_real),
-    imag = GetSetProperty(W_ComplexFloatingBox.descr_get_imag),
+    real = GetSetProperty(W_Complex64Box.descr_get_real),
+    imag = GetSetProperty(W_Complex64Box.descr_get_imag),
 )
diff --git a/pypy/module/micronumpy/test/test_ufuncs.py b/pypy/module/micronumpy/test/test_ufuncs.py
--- a/pypy/module/micronumpy/test/test_ufuncs.py
+++ b/pypy/module/micronumpy/test/test_ufuncs.py
@@ -914,4 +914,4 @@
 
     def test_complex_math(self):
         # from _numpypy import 
-        pass
\ No newline at end of file
+        pass


More information about the pypy-commit mailing list