[Numpy-discussion] Definition of correlation, correlate and so on ?

2006-12-11 Thread David Cournapeau
Hi, I am polishing some code to compute autocorrelation using fft, and when testing the code against numpy.correlate, I realised that I am not sure about the definition... There are various function related to correlation as far as numpy/scipoy is concerned: numpy.correlate nump

Re: [Numpy-discussion] a==b for numpy arrays

2006-12-11 Thread David Goldsmith
Abel Daniel wrote: > to what 'a+b' means with a and b being numpy arrays. But 'A=B' means something > completely different than 'a==b'. > > I disagree: A=B "on the blackboard" does mean that every element in A equals its positionally-corresponding element in B, and a==b in numpy will only be w

Re: [Numpy-discussion] a==b for numpy arrays

2006-12-11 Thread Christopher Barker
Steve Lianoglou wrote: >> a[where(a < 0)] = 0 > Ah ... I see, w/o the where returns a boolean array. I reckon that's > actually better to use than the where clause for cases like this > since (for one) it'll take up less memory than arrays of ints. not to mention that you're creating an entir

Re: [Numpy-discussion] fromfile and tofile access with a tempfile.TemporaryFile()

2006-12-11 Thread Charles R Harris
On 12/11/06, Tim Hirzel <[EMAIL PROTECTED]> wrote: Hi, Does anyone know how to get fromfile and tofile to work from a tempfile.TemporaryFile? Or if its not possible? I am getting this: >>> import tempfile >>> f = tempfile.TemporaryFile() >>> f ', mode 'w+b' at 0x01EE1728> >>> a = numpy.arange(

Re: [Numpy-discussion] a==b for numpy arrays

2006-12-11 Thread Keith Goodman
On 12/11/06, Steve Lianoglou <[EMAIL PROTECTED]> wrote: > > It's not relevant to the point of this discussion all that much, but: > > > >> a[a < 0] = 0 > >> a[less(a, 0)] = 0 > > > > Instead I've been doing something like: > > > > a[where(a < 0)] = 0 > > > > I didn't realized you could do it the ot

Re: [Numpy-discussion] a==b for numpy arrays

2006-12-11 Thread Steve Lianoglou
> It's not relevant to the point of this discussion all that much, but: > >> a[a < 0] = 0 >> a[less(a, 0)] = 0 > > Instead I've been doing something like: > > a[where(a < 0)] = 0 > > I didn't realized you could do it the other way. Is there a > difference somewhere between the two, or are they inte

Re: [Numpy-discussion] a==b for numpy arrays

2006-12-11 Thread Steve Lianoglou
Hi, It's not relevant to the point of this discussion all that much, but: > a[a < 0] = 0 > a[less(a, 0)] = 0 Instead I've been doing something like: a[where(a < 0)] = 0 I didn't realized you could do it the other way. Is there a difference somewhere between the two, or are they interchangeab

[Numpy-discussion] fromfile and tofile access with a tempfile.TemporaryFile()

2006-12-11 Thread Tim Hirzel
Hi, Does anyone know how to get fromfile and tofile to work from a tempfile.TemporaryFile? Or if its not possible? I am getting this: >>> import tempfile >>> f = tempfile.TemporaryFile() >>> f ', mode 'w+b' at 0x01EE1728> >>> a = numpy.arange(10) >>> a.tofile(f) Traceback (most recent call

Re: [Numpy-discussion] a==b for numpy arrays

2006-12-11 Thread Johannes Loehnert
Hi, > current behaviour. That is, what "A+B" on a blackboard in a math class > means maps nicely to what 'a+b' means with a and b being numpy arrays. But > 'A=B' means something completely different than 'a==b'. This mapping is dangerous, I think A+B and A-B might be the only cases where it actu

Re: [Numpy-discussion] a==b for numpy arrays

2006-12-11 Thread Robert Kern
Abel Daniel wrote: > Robert Kern gmail.com> writes: > >> Abel Daniel wrote: >>> Now, I think that having a way of getting an element-wise comparison >>> (i.e. getting an array of bools) is great. _But_ why make that the >>> result of a '==' comparison? Is there any actual code that does, for >>>

Re: [Numpy-discussion] a==b for numpy arrays

2006-12-11 Thread Tim Hochberg
Abel Daniel wrote: > Robert Kern gmail.com> writes: > > >> Abel Daniel wrote: >> >>> Now, I think that having a way of getting an element-wise comparison >>> (i.e. getting an array of bools) is great. _But_ why make that the >>> result of a '==' comparison? Is there any actual code that do

Re: [Numpy-discussion] a==b for numpy arrays

2006-12-11 Thread Abel Daniel
Robert Kern gmail.com> writes: > > Abel Daniel wrote: > > Now, I think that having a way of getting an element-wise comparison > > (i.e. getting an array of bools) is great. _But_ why make that the > > result of a '==' comparison? Is there any actual code that does, for > > example > result

Re: [Numpy-discussion] a==b for numpy arrays

2006-12-11 Thread Robert Kern
Abel Daniel wrote: > Hi! > > My unittests got broken because 'a==b' for numpy arrays returns an > array instead of returning True or False: > import numpy a = numpy.array([1, 2]) b = numpy.array([1, 4]) a==b > array([True, False], dtype=bool) > > This means, for example:

Re: [Numpy-discussion] a==b for numpy arrays

2006-12-11 Thread David Huard
Hi Daniel, Just out of curiosity, what's wrong with if all(a==b): ... ? Cheers, David 2006/12/11, Abel Daniel <[EMAIL PROTECTED]>: > Hi! My unittests got broken because 'a==b' for numpy arrays returns an array instead of returning True or False: >>> import numpy >>> a = numpy.array([1,

[Numpy-discussion] a==b for numpy arrays

2006-12-11 Thread Abel Daniel
> Hi! My unittests got broken because 'a==b' for numpy arrays returns an array instead of returning True or False: >>> import numpy >>> a = numpy.array([1, 2]) >>> b = numpy.array([1, 4]) >>> a==b array([True, False], dtype=bool) This means, for example: >>> if a==b: ... print 'equal' ... Trac

Re: [Numpy-discussion] Numeric memory leak when building Numeric.array from numarray.array

2006-12-11 Thread Francesc Altet
El dl 11 de 12 del 2006 a les 14:16 +0100, en/na Alexandre Fayolle va escriure: > > > I can work around this by using an intermediate string representation: > > > > > > temp = Numeric.fromstring(atest.tostring(), atest.typecode()) > > > temp.shape = atest.shape > > > > Another (faster) workaround

Re: [Numpy-discussion] lapack_lite dgesv

2006-12-11 Thread Tim Hochberg
R. David wrote: > Hello, > > > >> Try replacing 'int' with intc (or numpy.intc if you are not using >> 'import *'). The following 'works' for me in the sense that it doesn't >> throw any errors (although I imagine the results are nonsense): >> > Thanks, it works now !! > Great. Glad th

Re: [Numpy-discussion] lapack_lite dgesv

2006-12-11 Thread R. David
Hello, > Try replacing 'int' with intc (or numpy.intc if you are not using > 'import *'). The following 'works' for me in the sense that it doesn't > throw any errors (although I imagine the results are nonsense): Thanks, it works now !! Sorry for non including the whole code, I just not wante

Re: [Numpy-discussion] lapack_lite dgesv

2006-12-11 Thread Tim Hochberg
R. David wrote: > Hello Tim, > >> The problem is probably your definition of ipiv. "(DIM)" is just a >> parenthesized scalar, what you probably want is "(DIM,)", which is a >> one-tuple. Personally, I'd recommend using list notation ("[nbrows, >> nbcols]", "[DIM]") rather than tuple notation

Re: [Numpy-discussion] lapack_lite dgesv

2006-12-11 Thread R. David
Hello Tim, > > The problem is probably your definition of ipiv. "(DIM)" is just a > parenthesized scalar, what you probably want is "(DIM,)", which is a > one-tuple. Personally, I'd recommend using list notation ("[nbrows, > nbcols]", "[DIM]") rather than tuple notation since it's both easier t

Re: [Numpy-discussion] lapack_lite dgesv

2006-12-11 Thread Tim Hochberg
R. David wrote: > Hello, > > I am trying to use the lapack_lite dgesv routine. > > The following sample code : > > from numpy import * > [] > a=zeros((nbrows,nbcols),float,order='C') > [] > ipiv=zeros((DIM),int,order='C') > [] > linalg.lapack_lite.dgesv(DIM,1,a,DIM,asarray(ipiv),b,DIM,i

Re: [Numpy-discussion] Numeric memory leak when building Numeric.array from numarray.array

2006-12-11 Thread Alexandre Fayolle
On Thu, Dec 07, 2006 at 05:36:22PM +0100, Francesc Altet wrote: > El dj 07 de 12 del 2006 a les 16:50 +0100, en/na Alexandre Fayolle va > escriure: > > Hi, > > > > I'm facing a memory leak on an application that has to use numarray and > > Numeric (because of external dependencies). > > > > The

[Numpy-discussion] lapack_lite dgesv

2006-12-11 Thread R. David
Hello, I am trying to use the lapack_lite dgesv routine. The following sample code : from numpy import * [] a=zeros((nbrows,nbcols),float,order='C') [] ipiv=zeros((DIM),int,order='C') [] linalg.lapack_lite.dgesv(DIM,1,a,DIM,asarray(ipiv),b,DIM,info) leads do the followin error messa