Author: Ronan Lamy <[email protected]>
Branch: fix-broken-types
Changeset: r93077:1497f86a109d
Date: 2016-11-23 07:27 +0000
http://bitbucket.org/pypy/pypy/changeset/1497f86a109d/

Log:    fix some translation issues

diff --git a/pypy/module/_cffi_backend/ctypeprim.py 
b/pypy/module/_cffi_backend/ctypeprim.py
--- a/pypy/module/_cffi_backend/ctypeprim.py
+++ b/pypy/module/_cffi_backend/ctypeprim.py
@@ -384,9 +384,9 @@
             w_ob = w_ob.convert_to_object()
         #
         if space.isinstance_w(w_ob, space.w_str):
-            value = self.cast_str(w_ob)
+            value = float(self.cast_str(w_ob))
         elif space.isinstance_w(w_ob, space.w_unicode):
-            value = self.cast_unicode(w_ob)
+            value = float(self.cast_unicode(w_ob))
         else:
             value = space.float_w(w_ob)
         w_cdata = cdataobj.W_CDataMem(space, self)
diff --git a/pypy/module/math/interp_math.py b/pypy/module/math/interp_math.py
--- a/pypy/module/math/interp_math.py
+++ b/pypy/module/math/interp_math.py
@@ -341,7 +341,7 @@
     if partials:
         hi = partials[-1]
         j = 0
-        lo = 0
+        lo = 0.0
         for j in range(len(partials) - 2, -1, -1):
             v = hi
             y = partials[j]
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
@@ -454,8 +454,8 @@
             return Float64(self.space).box(self.unbox(v))
         # numpy 1.10 compatibility
         raise oefmt(self.space.w_TypeError, "ufunc casting failure")
-            
-            
+
+
 
 class Integer(Primitive):
     _mixin_ = True
@@ -1058,9 +1058,9 @@
     def logaddexp2(self, v1, v2):
         tmp = v1 - v2
         if tmp > 0:
-            return v1 + self.npy_log2_1p(math.pow(2, -tmp))
+            return v1 + self.npy_log2_1p(math.pow(2., -tmp))
         if tmp <= 0:
-            return v2 + self.npy_log2_1p(math.pow(2, tmp))
+            return v2 + self.npy_log2_1p(math.pow(2., tmp))
         else:
             return v1 + v2
 
@@ -1179,11 +1179,11 @@
         imag_str += 'j'
 
         # (0+2j) => 2j
-        if real == 0 and math.copysign(1, real) == 1:
+        if real == 0. and math.copysign(1., real) == 1.:
             return imag_str
 
         real_str = str_format(real)
-        op = '+' if imag >= 0 or rfloat.isnan(imag) else ''
+        op = '+' if imag >= 0. or rfloat.isnan(imag) else ''
         return ''.join(['(', real_str, op, imag_str, ')'])
 
     def runpack_str(self, space, s, native):
@@ -1501,13 +1501,13 @@
             return rfloat.NAN, 0
         if v[0] == 0.0:
             if v[1] == 0:
-                return 0, 0
+                return 0., 0
             if v[1] > 0:
-                return 1, 0
-            return -1, 0
+                return 1., 0
+            return -1., 0
         if v[0] > 0:
-            return 1, 0
-        return -1, 0
+            return 1., 0
+        return -1., 0
 
     def fmax(self, v1, v2):
         if self.ge(v1, v2) or self.isnan(v2):
diff --git a/pypy/objspace/std/complexobject.py 
b/pypy/objspace/std/complexobject.py
--- a/pypy/objspace/std/complexobject.py
+++ b/pypy/objspace/std/complexobject.py
@@ -220,7 +220,7 @@
         div = math.floor(w_div.realval)
         w_mod = self.sub(
             W_ComplexObject(other.realval * div, other.imagval * div))
-        return (W_ComplexObject(div, 0), w_mod)
+        return (W_ComplexObject(div, 0.), w_mod)
 
     def pow(self, other):
         rr, ir = rcomplex.c_pow(self.as_tuple(), other.as_tuple())
diff --git a/pypy/objspace/std/floatobject.py b/pypy/objspace/std/floatobject.py
--- a/pypy/objspace/std/floatobject.py
+++ b/pypy/objspace/std/floatobject.py
@@ -336,7 +336,7 @@
                     raise oefmt(space.w_OverflowError, "too large")
                 else:
                     lsb = max(top_exp, rfloat.DBL_MIN_EXP) - 
rfloat.DBL_MANT_DIG
-                    value = 0
+                    value = 0.
                     if exp >= lsb:
                         for j in range(total_digits - 1, -1, -1):
                             value = 16.0 * value + _hex_digit(s, j, co_end,
diff --git a/rpython/rlib/rcomplex.py b/rpython/rlib/rcomplex.py
--- a/rpython/rlib/rcomplex.py
+++ b/rpython/rlib/rcomplex.py
@@ -70,11 +70,11 @@
 
 def c_pow(x, y):
     (r1, i1), (r2, i2) = x, y
-    if i1 == 0 and i2 == 0 and r1 > 0:
+    if i1 == 0. and i2 == 0. and r1 > 0.:
         rr = math.pow(r1, r2)
         ir = 0.
     elif r2 == 0.0 and i2 == 0.0:
-        rr, ir = 1, 0
+        rr, ir = 1., 0.
     elif r1 == 1.0 and i1 == 0.0:
         rr, ir = (1.0, 0.0)
     elif r1 == 0.0 and i1 == 0.0:
@@ -108,22 +108,22 @@
     Method: use symmetries to reduce to the case when x = z.real and y
     = z.imag are nonnegative.  Then the real part of the result is
     given by
-    
+
       s = sqrt((x + hypot(x, y))/2)
-    
+
     and the imaginary part is
-    
+
       d = (y/2)/s
-    
+
     If either x or y is very large then there's a risk of overflow in
     computation of the expression x + hypot(x, y).  We can avoid this
     by rewriting the formula for s as:
-    
+
       s = 2*sqrt(x/8 + hypot(x/8, y/8))
-    
+
     This costs us two extra multiplications/divisions, but avoids the
     overhead of checking for x and y large.
-    
+
     If both x and y are subnormal then hypot(x, y) may also be
     subnormal, so will lack full precision.  We solve this by rescaling
     x and y by a sufficiently large power of 2 to ensure that x and y
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to