[Numpy-discussion] Slicing a numpy array and getting the "complement"

Orest Kozyar orest.kozyar@gmail....
Mon May 19 09:34:37 CDT 2008


Given a slice, such as s_[..., :-2:], is it possible to take the
complement of this slice?  Specifically, s_[..., ::-2].  I have a
series of 2D arrays that I need to split into two subarrays via
slicing where the members of the second array are all the members
leftover from the slice.  The problem is that the slice itself will
vary, and could be anything such as s_[..., 1:4:] or s_[..., 1:-4:],
etc, so I'm wondering if there's a straightforward idiom or routine in
Numpy that would facilitate taking the complement of a slice?  I've
looked around the docs, and have not had much luck.

Thanks!
Orest


More information about the Numpy-discussion mailing list