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
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
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
> 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
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
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
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
>>>
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
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
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:
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,
>
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
12 matches
Mail list logo