Reputation: 688
Today python stopped finding None in a numpy array. My code breaks because of the following. Any clue appreciated.
In [36]: abc = np.array([3,2,None])
In [37]: None is abc[-1]
Out[37]: True
In [38]: None in abc
/Users/py/htrans.py:1: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future. #!/usr/bin/env python3
Out[38]: False
In [39]: abc==None
/Users/py/htrans.py:1: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future. #!/usr/bin/env python3
Out[39]: False
sys.platform
Out[42]: 'darwin'
sys.version
Out[43]: '3.5.1 |Anaconda 4.0.0 (x86_64)| (default, Dec 7 2015, 11:24:55) \n[GCC 4.2.1 (Apple Inc. build 5577)]'
np.version.version
Out[44]: '1.10.4'
Upvotes: 0
Views: 96
Reputation: 2676
Link: https://github.com/numpy/numpy/issues/1608
According to the link, this bug was reported and fixed in the 1.13.0 release of Numpy.
A quick workaround you can use is:
any(elem is None for elem in abc)
Upvotes: 2