Skip to content

Instantly share code, notes, and snippets.

@chrisgorgo
Created May 13, 2015 20:52
Show Gist options
  • Save chrisgorgo/7042d58d4d3227535fab to your computer and use it in GitHub Desktop.
Save chrisgorgo/7042d58d4d3227535fab to your computer and use it in GitHub Desktop.
axis = 2
new_shape = list(x.shape)
del new_shape[axis]
a1, a2 = np.indices(new_shape)
inds = [a1, a2]
inds.insert(axis, x.argmax(axis=axis))
x[inds[0], inds[1], inds[2]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment