summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/shape_base.py2
-rw-r--r--numpy/lib/tests/test_shape_base.py6
2 files changed, 7 insertions, 1 deletions
diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py
index e580690d1..6e92aa041 100644
--- a/numpy/lib/shape_base.py
+++ b/numpy/lib/shape_base.py
@@ -127,7 +127,7 @@ def apply_along_axis(func1d, axis, arr, *args, **kwargs):
ind[n] = 0
n -= 1
i.put(indlist, ind)
- res = func1d(arr[tuple(i.tolist())], *args, **kwargs)
+ res = asanyarray(func1d(arr[tuple(i.tolist())], *args, **kwargs))
outarr[tuple(i.tolist())] = res
k += 1
if res.shape == ():
diff --git a/numpy/lib/tests/test_shape_base.py b/numpy/lib/tests/test_shape_base.py
index 2eb4a809d..a716d3b38 100644
--- a/numpy/lib/tests/test_shape_base.py
+++ b/numpy/lib/tests/test_shape_base.py
@@ -58,6 +58,12 @@ class TestApplyAlongAxis(TestCase):
assert isinstance(res, MinimalSubclass)
assert_array_equal(res, np.array([6, 6, 6]).view(MinimalSubclass))
+ def test_tuple_func1d(self):
+ def sample_1d(x):
+ return x[1], x[0]
+ res = np.apply_along_axis(sample_1d, 1, np.array([[1, 2], [3, 4]]))
+ assert_array_equal(res, np.array([[2, 1], [4, 3]]))
+
class TestApplyOverAxes(TestCase):
def test_simple(self):