Oh sorry, my fault...
here is the answer by Nathaniel Smith:
def retrieve_data(a, ax, idx):
full_idx = [slice(None)] * a.ndim
full_idx[ax] = idx
return a[tuple(full_idx)]
Or for the specific case where you do know the axis in advance, you just
don't know how many trailing axes there
Hi Neal,
I forward you this mail which I think might be of help to your question.
Chao
-- Forwarded message --
From: Chao YUE
Date: Sat, Mar 16, 2013 at 5:40 PM
Subject: indexing of arbitrary axis and arbitrary slice?
To: Discussion of Numerical Python
Dear all,
Is there som
In the following code, the function maxstar is applied along the
last axis. Can anyone suggest how to modify this to apply reduction along
a user-specified axis?
def maxstar2 (a, b):
return max (a, b) + log1p (exp (-abs (a - b)))
def maxstar (u):
s = u.shape[-1]
if s == 1:
r