[Numpy-discussion] flatiter and inequality comparison
Travis Oliphant
oliphant at ee.byu.edu
Fri Jun 23 16:19:13 CDT 2006
Alan G Isaac wrote:
>I do not understand how to think about this:
>
> >>> x=arange(3).flat
> >>> x
> <numpy.flatiter object at 0x01BD0C58>
> >>> x>2
> True
> >>> x>10
> True
>
>Why? (I realize this behaves like xrange,
>so this may not be a numpy question,
>but I do not understand that behavior either.)
>
>
The flatiter object didn't have comparisons implemented so I guess it
was using some default implementation. This is quite confusing and
option 2 does make sense (an array of resulting comparisions is returned).
Thus now:
>> x=arange(3).flat
>>> x>2
array([False, False, False], dtype=bool)
>>> x>1
array([False, False, True], dtype=bool)
>>> x>0
array([False, True, True], dtype=bool)
-Travis
More information about the Numpy-discussion
mailing list