Advertisement
Guest User

numpy 1.8.0 apply_along_axis named arguments

a guest
Mar 6th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.56 KB | None | 0 0
  1. --- shape_base.py   2014-03-06 13:18:57.014449386 +0100
  2. +++ /lib/python2.7/site-packages/numpy/lib/shape_base.py    2014-03-06 11:36:44.373984020 +0100
  3. @@ -10,7 +10,7 @@
  4.  from numpy.core.fromnumeric import product, reshape
  5.  from numpy.core import hstack, vstack, atleast_3d
  6.  
  7. -def apply_along_axis(func1d,axis,arr,*args):
  8. +def apply_along_axis(func1d,axis,arr,*args,**moreargs):
  9.      """
  10.     Apply a function to 1-D slices along the given axis.
  11.  
  12. @@ -76,7 +76,8 @@
  13.     i[axis] = slice(None, None)
  14.     outshape = asarray(arr.shape).take(indlist)
  15.     i.put(indlist, ind)
  16. -    res = func1d(arr[tuple(i.tolist())],*args)
  17. +    print
  18. +    res = func1d(arr[tuple(i.tolist())],*args,**moreargs)
  19.     #  if res is a number, then we have a smaller output array
  20.     if isscalar(res):
  21.         outarr = zeros(outshape, asarray(res).dtype)
  22. @@ -92,7 +93,7 @@
  23.                 ind[n] = 0
  24.                 n -= 1
  25.             i.put(indlist, ind)
  26. -            res = func1d(arr[tuple(i.tolist())],*args)
  27. +            res = func1d(arr[tuple(i.tolist())],*args,**moreargs)
  28.             outarr[tuple(ind)] = res
  29.             k += 1
  30.         return outarr
  31. @@ -113,7 +114,7 @@
  32.                 ind[n] = 0
  33.                 n -= 1
  34.             i.put(indlist, ind)
  35. -            res = func1d(arr[tuple(i.tolist())],*args)
  36. +            res = func1d(arr[tuple(i.tolist())],*args,**moreargs)
  37.             outarr[tuple(i.tolist())] = res
  38.             k += 1
  39.         return outarr
  40. @@ -832,4 +833,3 @@
  41.         shape[i] = dim_out
  42.         n //= max(dim_in, 1)
  43.     return c.reshape(shape)
  44. -
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement