Commits

Taavi Burns committed 382d1c9

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

Comments (0)

Files changed (1)

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):