Commits

Taavi Burns  committed 382d1c9

Update trunc to use the same implementation as numpy. Works around some "won't work in pypy" issues.

  • Participants
  • Parent commits 68288dd
  • Branches numpy-ufuncs3

Comments (0)

Files changed (1)

File pypy/module/micronumpy/types.py

 
     @simple_unary_op
     def trunc(self, v):
-        try:
-            return int(v)
-        except OverflowError:
-            return rfloat.copysign(rfloat.INFINITY, v)
-        except ValueError:
-            return v
+        if v < 0:
+            return math.ceil(v)
+        else:
+            return math.floor(v)
 
     @simple_unary_op
     def exp(self, v):