[Numpy-discussion] Simple problem. Is it possible without a loop?
"V. Armando Solé"
Wed Jun 9 03:00:50 CDT 2010
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)
Sorry for the time taken!
V. Armando Solé wrote:
> I am trying to solve a simple problem that becomes complex if I try to
> avoid looping.
> Let's say I have a 1D array, x, where x[i] <= x[i+1]
> Given a certain value delta, I would like to get a subset of x, named y,
> where (y[i+1] - y[i]) >= delta
> In a non-optimized and trivial way, the operation I would like to do is:
> for value in x:
> if (y[-1] -value) < delta:
> Any hint?
> Best regards,
> NumPy-Discussion mailing list
More information about the NumPy-Discussion