Author: Ronan Lamy <[email protected]>
Branch: longdouble2
Changeset: r62864:1e26abd5e420
Date: 2013-03-29 04:29 +0000
http://bitbucket.org/pypy/pypy/changeset/1e26abd5e420/

Log:    kill ComplexFloating.composite()

diff --git a/pypy/module/micronumpy/arrayimpl/scalar.py 
b/pypy/module/micronumpy/arrayimpl/scalar.py
--- a/pypy/module/micronumpy/arrayimpl/scalar.py
+++ b/pypy/module/micronumpy/arrayimpl/scalar.py
@@ -71,18 +71,24 @@
 
     def set_real(self, space, orig_array, w_val):
         w_arr = convert_to_array(space, w_val)
-        dtype = self.dtype.float_type or self.dtype
         if len(w_arr.get_shape()) > 0:
             raise OperationError(space.w_ValueError, space.wrap(
                 "could not broadcast input array from shape " +
                 "(%s) into shape ()" % (
                     ','.join([str(x) for x in w_arr.get_shape()],))))
+        value = w_arr.get_scalar_value()
         if self.dtype.is_complex_type():
-            self.value = self.dtype.itemtype.composite(
-                               w_arr.get_scalar_value().convert_to(dtype),
-                               self.value.convert_imag_to(dtype))
+            self._set_real(self.value, value)
         else:
-            self.value = w_arr.get_scalar_value()
+            self.value = value
+
+    @specialize.argtype(1)
+    def _set_real(self, box, value):
+        from pypy.module.micronumpy.interp_dtype import W_ComplexDtype
+        assert isinstance(self.dtype, W_ComplexDtype)
+        float_type = self.dtype.float_type
+        box.set_real(value.convert_to(float_type))
+
 
     def get_imag(self, orig_array):
         if self.dtype.is_complex_type():
@@ -104,14 +110,14 @@
                 "(%s) into shape ()" % (
                     ','.join([str(x) for x in w_arr.get_shape()],))))
         value = w_arr.get_scalar_value()
-        self._set_imag(value)
+        self._set_imag(self.value, value)
 
     @specialize.argtype(1)
-    def _set_imag(self, value):
+    def _set_imag(self, box, value):
         from pypy.module.micronumpy.interp_dtype import W_ComplexDtype
         assert isinstance(self.dtype, W_ComplexDtype)
-        dtype = self.dtype.float_type
-        self.value.imag = value.convert_to(dtype)
+        float_type = self.dtype.float_type
+        box.set_imag(value.convert_to(float_type))
 
     def descr_getitem(self, space, _, w_idx):
         raise OperationError(space.w_IndexError,
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
@@ -65,6 +65,14 @@
     def convert_imag_to(self, dtype):
         return dtype.box(self.imag)
 
+    def set_real(self, box):
+        assert isinstance(box, self._COMPONENTS_BOX)
+        self.real = box.value
+
+    def set_imag(self, box):
+        assert isinstance(box, self._COMPONENTS_BOX)
+        self.imag = box.value
+
 
 class W_GenericBox(W_Root):
     _attrs_ = ()
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
@@ -1149,14 +1149,6 @@
                 return rfloat.NAN, rfloat.NAN
             return rfloat.INFINITY, rfloat.INFINITY
 
-    @specialize.argtype(1)
-    def composite(self, v1, v2):
-        assert isinstance(v1, self.ComponentBoxType)
-        assert isinstance(v2, self.ComponentBoxType)
-        real = v1.value
-        imag = v2.value
-        return self.box_complex(real, imag)
-
     @complex_unary_op
     def pos(self, v):
         return v
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to