[pypy-commit] pypy nupypy-axis-arg-check: minor cleanup

mattip noreply at buildbot.pypy.org
Sat Jun 16 22:30:56 CEST 2012


Author: mattip <matti.picus at gmail.com>
Branch: nupypy-axis-arg-check
Changeset: r55700:94626e0756d0
Date: 2012-06-16 23:19 +0300
http://bitbucket.org/pypy/pypy/changeset/94626e0756d0/

Log:	minor cleanup

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
@@ -15,6 +15,7 @@
 from pypy.rlib.rstring import StringBuilder
 from pypy.rpython.lltypesystem import lltype, rffi
 from pypy.tool.sourcetools import func_with_new_name
+from pypy.module.micronumpy.interp_support import unwrap_axis_arg
 
 
 count_driver = jit.JitDriver(
@@ -568,14 +569,7 @@
         if space.is_w(w_axis, space.w_None):
             w_denom = space.wrap(support.product(self.shape))
         else:
-            axis = space.int_w(w_axis)
-            shapelen = len(self.shape)
-            if axis < -shapelen or axis>= shapelen:
-                raise operationerrfmt(space.w_ValueError,
-                    "axis entry %d is out of bounds [%d, %d)", axis,
-                    -shapelen, shapelen)
-            if axis < 0:    
-                axis += shapelen
+            axis = unwrap_axis_arg(space, len(self.shape), w_axis)
             w_denom = space.wrap(self.shape[axis])
         return space.div(self.descr_sum_promote(space, w_axis, w_out), w_denom)
 
@@ -969,7 +963,6 @@
     def __init__(self, ufunc, name, identity, shape, dtype, left, right, dim):
         Call2.__init__(self, ufunc, name, shape, dtype, dtype,
                        left, right)
-        assert dim >= 0
         self.dim = dim
         self.identity = identity
 


More information about the pypy-commit mailing list