0

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'
10
  • 2
    What does type(None) show and what does None is seq[wave:wave+lead][-1] show? Commented Sep 15, 2018 at 15:13
  • ipdb> type(None) <class 'NoneType'> ipdb> None is seq[wave:wave+lead] False ipdb> Commented Sep 15, 2018 at 15:15
  • 3
    Did you include the [-1] there? Commented Sep 15, 2018 at 15:16
  • ipdb> None is seq[wave:wave+lead][-1] True Commented Sep 15, 2018 at 15:16
  • 2
    Curious... and what does seq[wave:wave_lead] == None give? Commented Sep 15, 2018 at 15:19

1 Answer 1

2

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)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.