[Numpy-discussion] Simple problem. Is it possible without a loop?

Francesc Alted faltet at pytables.org
Wed Jun 9 04:16:00 EDT 2010


Yeah, damn you! ;-)

A Wednesday 09 June 2010 10:11:33 Robert Elsner escrigué:
> Hah beat you to it one minute ;)
> 
> Am Mittwoch, den 09.06.2010, 10:08 +0200 schrieb Francesc Alted:
> > A Wednesday 09 June 2010 10:00:50 V. Armando Solé escrigué:
> > > Well, this seems to be quite close to what I need
> > >
> > > y = numpy.cumsum((x[1:]-x[:-1])/delta).astype(numpy.int)
> > > i1 = numpy.nonzero(y[1:] > y[:-1])
> > > y = numpy.take(x, i1)
> >
> > Perhaps this is a bit shorter:
> >
> > y = x[(x[1:] - x[:-1]) >= delta]
> 
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
> 

-- 
Francesc Alted



More information about the NumPy-Discussion mailing list