Is there a way to slice an nd-array along a specified axis? It's easy to slice along a fixed axis, e.g.:
axis = 0: >>> array[start:end] axis = 1: >>> array[:, start:end] ... But I need to do this inside of a function that accepts arrays of any dimension, and the user can operate on any axis of the array. My current solution looks like the following: >>> aslice = lambda axis, s, e: (slice(None),) * axis + (slice(s, e),) >>> array[aslice(axis, start, end)] which works, but I'm guessing that numpy has a more readable way of doing this that I've overlooked. Thanks, -Tony
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion