[pypy-commit] pypy ndarray-subtype: match strange implementation of round() in numpy

mattip noreply at buildbot.pypy.org
Sun Jul 14 19:03:43 CEST 2013


Author: Matti Picus <matti.picus at gmail.com>
Branch: ndarray-subtype
Changeset: r65388:8281a068e40f
Date: 2013-07-14 00:54 +0300
http://bitbucket.org/pypy/pypy/changeset/8281a068e40f/

Log:	match strange implementation of round() in numpy

diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -589,6 +589,8 @@
         else:
             calc_dtype = out.get_dtype()
 
+        if decimals == 0:
+            out = out.descr_view(space,space.type(self))
         loop.round(space, self, calc_dtype, self.get_shape(), decimals, out)
         return out
 
diff --git a/pypy/module/micronumpy/test/test_subtype.py b/pypy/module/micronumpy/test/test_subtype.py
--- a/pypy/module/micronumpy/test/test_subtype.py
+++ b/pypy/module/micronumpy/test/test_subtype.py
@@ -131,11 +131,11 @@
         from numpypy import array
         a = array(range(10), dtype=float).view(self.NoNew)
         # numpy compatibility
-        b = a.round(decimal=0)
+        b = a.round(decimals=0)
         assert isinstance(b, self.NoNew)
-        b = a.round(decimal=1)
+        b = a.round(decimals=1)
         assert not isinstance(b, self.NoNew)
-        b = a.round(decimal=-1)
+        b = a.round(decimals=-1)
         assert not isinstance(b, self.NoNew)
 
     def test_sub_dot(self):


More information about the pypy-commit mailing list