[Numpy-discussion] str == int puzzlement
Sturla Molden
sturla at molden.no
Wed Jul 28 22:04:28 EDT 2010
> 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
>
> Is it easy to explain why this is?
I'll call this a bug in NumPy's broadcasting. "x == 1" should have returned:
array([ False, False], dtype=bool)
Sturla
More information about the NumPy-Discussion
mailing list