[pypy-commit] pypy default: Removes duplicate code (rint is effectively round, for complex types).

taavi_burns noreply at buildbot.pypy.org
Tue Aug 13 17:42:23 CEST 2013


Author: Taavi Burns <taavi.burns at gmail.com>
Branch: 
Changeset: r66118:99a209086e0a
Date: 2013-08-13 11:05 -0400
http://bitbucket.org/pypy/pypy/changeset/99a209086e0a/

Log:	Removes duplicate code (rint is effectively round, for complex
	types).

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
@@ -1341,15 +1341,6 @@
     #    return (rfloat.copysign(v1[0], v2[0]),
     #           rfloat.copysign(v1[1], v2[1]))
 
-    @specialize.argtype(1)
-    def rint(self, v):
-        ans = list(self.for_computation(self.unbox(v)))
-        if isfinite(ans[0]):
-            ans[0] = rfloat.round_double(ans[0], 0, half_even=True)
-        if isfinite(ans[1]):
-            ans[1] = rfloat.round_double(ans[1], 0, half_even=True)
-        return self.box_complex(ans[0], ans[1])
-
     @complex_unary_op
     def sign(self, v):
         '''
@@ -1408,11 +1399,14 @@
     def round(self, v, decimals=0):
         ans = list(self.for_computation(self.unbox(v)))
         if isfinite(ans[0]):
-            ans[0] = rfloat.round_double(ans[0], decimals,  half_even=True)
+            ans[0] = rfloat.round_double(ans[0], decimals, half_even=True)
         if isfinite(ans[1]):
-            ans[1] = rfloat.round_double(ans[1], decimals,  half_even=True)
+            ans[1] = rfloat.round_double(ans[1], decimals, half_even=True)
         return self.box_complex(ans[0], ans[1])
 
+    def rint(self, v):
+        return self.round(v)
+
     # No floor, ceil, trunc in numpy for complex
     #@simple_unary_op
     #def floor(self, v):


More information about the pypy-commit mailing list