Re: [Numpy-discussion] dunno what array operation I'm looking for...

2008-03-22 Thread Joris De Ridder
On 22 Mar 2008, at 13:49, Chris Withers wrote: > Joris De Ridder wrote: >> numpy.diff >> See http://www.scipy.org/Numpy_Example_List > > Cool :-) > > Both this and Hoyt's example do exactly what I want. > > I'm guessing diff is going to be more efficient though? No, not really, diff has more fun

Re: [Numpy-discussion] dunno what array operation I'm looking for...

2008-03-22 Thread Chris Withers
Joris De Ridder wrote: > numpy.diff > See http://www.scipy.org/Numpy_Example_List Cool :-) Both this and Hoyt's example do exactly what I want. I'm guessing diff is going to be more efficient though? cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - htt

Re: [Numpy-discussion] dunno what array operation I'm looking for...

2008-03-21 Thread Hoyt Koepke
Try result = A[1:] - A[:-1] --Hoyt On Fri, Mar 21, 2008 at 7:43 PM, Chris Withers <[EMAIL PROTECTED]> wrote: > Hi All, > > Say I have an array like: > > >>> measurements = array([100,109,115,117]) > > What do I do to it to get: > > array([9, 6, 2]) > > Is the following really the best way?

Re: [Numpy-discussion] dunno what array operation I'm looking for...

2008-03-21 Thread Joris De Ridder
numpy.diff See http://www.scipy.org/Numpy_Example_List J. On 22 Mar 2008, at 03:43, Chris Withers wrote: > Hi All, > > Say I have an array like: > measurements = array([100,109,115,117]) > > What do I do to it to get: > > array([9, 6, 2]) > > Is the following really the best way? >

[Numpy-discussion] dunno what array operation I'm looking for...

2008-03-21 Thread Chris Withers
Hi All, Say I have an array like: >>> measurements = array([100,109,115,117]) What do I do to it to get: array([9, 6, 2]) Is the following really the best way? >>> result = [] >>> for i in range(1,len(measurements)): ... result.append(measurements[i]-measurements[i-1]) ... >>> array(res