Author: Taavi Burns <[email protected]>
Branch: numpy-ufuncs3
Changeset: r54176:382d1c98cd25
Date: 2012-04-04 14:08 -0400
http://bitbucket.org/pypy/pypy/changeset/382d1c98cd25/

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

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
@@ -669,12 +669,10 @@
 
     @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):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to