Numeric slicing, iteration prob.

Jonathan Hogg jonathan at onegoodidea.com
Tue Aug 6 05:15:10 EDT 2002


On 5/8/2002 23:20, in article aimtmj$mg2$1 at peabody.colorado.edu, "Fernando
Perez" <fperez528 at yahoo.com> wrote:

> Can't think of a nicer one right now, but there probably is one. Maybe build
> the necessary index structures and use take()? Don't know...

I don't have NumPy installed (and don't know much about it), but can't you
just build the necessary tuple of slices and pass that in to []?

For multi-dimensional arrays I would sort of expect that:

>>> index = ( slice(0,-1), slice(2,5), Ellipsis )
>>> m[index]

should be the equivalent of:

>>> m[:,2:5,...]

I think ;-)

Jonathan




More information about the Python-list mailing list