[Numpy-discussion] Slices from an index list

Mads Ipsen madsipsen@gmail....
Wed Apr 11 04:28:57 CDT 2012


Hi,

Suppose a have an array of indices, say

   indices = [0,1,2,3,5,7,8,9,10,12,13,14]

Then the following slices

   a = slice(0,4)
   b = slice(4,5)
   c = slice(5,9)
   d = slice(9,12)

provide information about all the consecutive parts of the index list. 
Given the list of indices, is there some nifty numpy function that can 
generate the above slices for me (or their start and stop values)?

Best regards,

Mads

-- 
+-----------------------------------------------------+
| Mads Ipsen                                          |
+----------------------+------------------------------+
| Gåsebæksvej 7, 4. tv |                              |
| DK-2500 Valby        | phone:          +45-29716388 |
| Denmark              | email:  mads.ipsen@gmail.com |
+----------------------+------------------------------+


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


More information about the NumPy-Discussion mailing list