[Numpy-svn] r3497 - in trunk/numpy/lib: . tests

numpy-svn at scipy.org numpy-svn at scipy.org
Sun Jan 7 23:01:57 EST 2007


Author: timl
Date: 2007-01-07 22:01:52 -0600 (Sun, 07 Jan 2007)
New Revision: 3497

Modified:
   trunk/numpy/lib/shape_base.py
   trunk/numpy/lib/tests/test_shape_base.py
Log:
fix for #407 and add unit test for it

Modified: trunk/numpy/lib/shape_base.py
===================================================================
--- trunk/numpy/lib/shape_base.py	2007-01-08 03:43:54 UTC (rev 3496)
+++ trunk/numpy/lib/shape_base.py	2007-01-08 04:01:52 UTC (rev 3497)
@@ -31,7 +31,7 @@
     #  if res is a number, then we have a smaller output array
     if isscalar(res):
         outarr = zeros(outshape,asarray(res).dtype)
-        outarr[ind] = res
+        outarr[tuple(ind)] = res
         Ntot = product(outshape)
         k = 1
         while k < Ntot:
@@ -44,7 +44,7 @@
                 n -= 1
             i.put(indlist,ind)
             res = func1d(arr[tuple(i.tolist())],*args)
-            outarr[ind] = res
+            outarr[tuple(ind)] = res
             k += 1
         return outarr
     else:

Modified: trunk/numpy/lib/tests/test_shape_base.py
===================================================================
--- trunk/numpy/lib/tests/test_shape_base.py	2007-01-08 03:43:54 UTC (rev 3496)
+++ trunk/numpy/lib/tests/test_shape_base.py	2007-01-08 04:01:52 UTC (rev 3497)
@@ -14,6 +14,10 @@
         a = ones((10,101),'d')
         assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))
 
+    def check_3d(self):
+        a = arange(27).reshape((3,3,3))
+        assert_array_equal(apply_along_axis(sum,0,a), [[27,30,33],[36,39,42],[45,48,51]])
+
 class test_array_split(NumpyTestCase):
     def check_integer_0_split(self):
         a = arange(10)




More information about the Numpy-svn mailing list