def asum (a, dimension=None,keepdims=0):
     if type(a) == N.ndarray and a.dtype in [N.int_, N.short, N.ubyte]:
         a = a.astype(N.float_)
     if dimension == None:
         s = N.sum(N.ravel(a))
     elif type(dimension) in [IntType,FloatType]:
         s = N.add.reduce(a, dimension)
         if keepdims == 1:
             shp = list(a.shape)
             shp[dimension] = 1
             s = N.reshape(s,shp)
     else: # must be a SEQUENCE of dims to sum over
        dims = list(dimension)
        dims.sort()
        dims.reverse()
        s = a *1.0
        for dim in dims:
            s = N.add.reduce(s,dim)
        if keepdims == 1:
            shp = list(a.shape)
            for dim in dims:
                shp[dim] = 1
            s = N.reshape(s,shp)
     return s
An alternative to the Numeric.add.reduce function, which allows one to
dataset/ETHPy150Open radlab/sparrow/src/main/python/third_party/stats.py/asum