[Numpy-discussion] str == int puzzlement

Keith Goodman kwgoodman@gmail....
Thu Jul 29 14:32:00 CDT 2010


On Wed, Jul 28, 2010 at 6:42 PM, Matthew Brett <matthew.brett@gmail.com> wrote:
> Hi,
>
> Please forgive me if this is obvious, but this surprised me:
>
> In [15]: x = np.array(['a', 'b'])
>
> In [16]: x == 'a'  # this was what I expected
> Out[16]: array([ True, False], dtype=bool)
>
> In [17]: x == 1 # this was strange to me
> Out[17]: False

Here's a related case:

>> np.array(['a', 'b']) == np.array([1, 2])
   False


More information about the NumPy-Discussion mailing list