8000 BUG: Fix crash on 0d return value in apply_along_axis by eric-wieser · Pull Request #8441 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fix crash on 0d return value in apply_along_axis #8441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 12, 2017
Prev Previous commit
Next Next commit
BUG: Call __array_prepare__ before __array_wrap__
  • Loading branch information
eric-wieser committed Feb 11, 2017
commit b10b6c290ded55e410543b9d09686042be3db6ec
5 changes: 4 additions & 1 deletion numpy/lib/shape_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def apply_along_axis(func1d, axis, arr, *args, **kwargs):
# insert as many axes as necessary to create the output
outshape = arr.shape[:axis] + res.shape + arr.shape[axis+1:]
outarr = zeros(outshape, res.dtype)
outarr = res.__array_wrap__(outarr)
outarr = res.__array_prepare__(outarr)

# outarr, with inserted dimensions at the end
# this means that outarr_view[i] = func1d(inarr_view[i])
Expand All @@ -127,6 +127,9 @@ def apply_along_axis(func1d, axis, arr, *args, **kwargs):
outarr_view[ind0] = res
for ind in inds:
outarr_view[ind] = asanyarray(func1d(inarr_view[ind], *args, **kwargs))

outarr = res.__array_wrap__(outarr)

return outarr


Expand Down
0