Re: [Numpy-discussion] breaking array indices

2011-06-02 Thread Mathew Yeates
thanks. My solution was much hackier. -Mathew On Thu, Jun 2, 2011 at 10:27 AM, Olivier Delalleau wrote: > I think this does what you want: > > def seq_split(x): >   r = [0] + list(numpy.where(x[1:] != x[:-1] + 1)[0] + 1) + [None] >   return [x[r[i]:r[i + 1]] for i in xrange(len(r) - 1)] > > -=-

Re: [Numpy-discussion] breaking array indices

2011-06-02 Thread Olivier Delalleau
I think this does what you want: def seq_split(x): r = [0] + list(numpy.where(x[1:] != x[:-1] + 1)[0] + 1) + [None] return [x[r[i]:r[i + 1]] for i in xrange(len(r) - 1)] -=- Olivier 2011/6/2 Mathew Yeates > Hi > I have indices into an array I'd like split so they are sequential > e.g. > [1

[Numpy-discussion] breaking array indices

2011-06-02 Thread Mathew Yeates
Hi I have indices into an array I'd like split so they are sequential e.g. [1,2,3,10,11] -> [1,2,3],[10,11] How do I do this? -Mathew ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion