Commits

mattip committed 94626e0

minor cleanup

Comments (0)

Files changed (1)

pypy/module/micronumpy/interp_numarray.py

 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(
         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)
 
     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
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.