Author: Matti Picus <[email protected]>
Branch: ndarray-round
Changeset: r64988:0e990018147d
Date: 2013-06-25 23:05 +0300
http://bitbucket.org/pypy/pypy/changeset/0e990018147d/

Log:    fix translation

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
@@ -523,9 +523,12 @@
 
     @specialize.argtype(1)
     def round(self, v, decimals=0):
-        raw = self.unbox(v)
+        raw = self.for_computation(self.unbox(v))
         if decimals < 0:
-            factor = int(10 ** -decimals)
+            # No ** in rpython
+            factor = 1
+            for i in xrange(-decimals):
+                factor *=10
             #int does floor division, we want toward zero
             if raw < 0:
                 ans = - (-raw / factor * factor)
@@ -814,7 +817,7 @@
 
     @specialize.argtype(1)
     def round(self, v, decimals=0):
-        raw = self.unbox(v)
+        raw = self.for_computation(self.unbox(v))
         if rfloat.isinf(raw):
             return v
         elif rfloat.isnan(raw):
@@ -1380,12 +1383,12 @@
 
     @specialize.argtype(1)
     def round(self, v, decimals=0):
-        ans = list(self.unbox(v))
+        ans = list(self.for_computation(self.unbox(v)))
         if isfinite(ans[0]):
             ans[0] = rfloat.round_double(ans[0], decimals,  half_even=True)
         if isfinite(ans[1]):
             ans[1] = rfloat.round_double(ans[1], decimals,  half_even=True)
-        return self.box_complex(*ans)
+        return self.box_complex(ans[0], ans[1])
 
     # No floor, ceil, trunc in numpy for complex
     #@simple_unary_op
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to