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] 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

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