[pypy-commit] pypy numpy-ufuncs3: Update trunc to use the same implementation as numpy. Works around some "won't work in pypy" issues.
taavi_burns
noreply at buildbot.pypy.org
Wed Apr 4 20:34:17 CEST 2012
Author: Taavi Burns <taavi.burns at gmail.com>
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):
More information about the pypy-commit
mailing list