[Numpy-discussion] bug in comparing object arrays to None (?)

Warren Weckesser warren.weckesser at gmail.com
Mon Jan 27 15:51:44 EST 2014


On Mon, Jan 27, 2014 at 3:43 PM, Charles G. Waldman <charles at crunch.io>wrote:

> Hi Numpy folks.
>
> I just noticed that comparing an array of type 'object' to None does
> not behave as I expected.  Is this a feature or a bug?  (I can take a
> stab at fixing it if it's a bug, as I believe it is).
>
> >>> np.version.full_version
> '1.8.0'
>
> >>> a = np.array(['Frank', None, 'Nancy'])
>
> >>> a
> array(['Frank', None, 'Nancy'], dtype=object)
>
> >>> a == 'Frank'
> array([ True, False, False], dtype=bool)
> # Return value is an array
>
> >>> a == None
> False
> # Return value is scalar (BUG?)
>


Looks like a fix is in progress:  https://github.com/numpy/numpy/pull/3514

Warren

_______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140127/40256891/attachment.html>


More information about the NumPy-Discussion mailing list