[Numpy-discussion] Slice specified axis

Benjamin Root ben.root@ou....
Fri Apr 6 07:54:35 CDT 2012

On Friday, April 6, 2012, Val Kalatsky wrote:

> The only slicing short-cut I can think of is the Ellipsis object, but it's
> not going to help you much here.
> The alternatives that come to my mind are (1) manipulation of shape
> directly and (2) building a string and running eval on it.
> Your solution is better than (1), and (2) is a horrible hack, so your
> solution wins again.
> Cheers
> Val

Take a peek at how np.gradient() does it.  It creates a list of None with a
length equal to the number of dimensions, and then inserts a slice object
in the appropriate spot in the list.

Ben Root

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120406/1df6d1e8/attachment.html 

More information about the NumPy-Discussion mailing list