title: Python numpy.nan and logical functions: wrong results
body: <p>I get some surprising results when trying to evaluate
  logical expressions on data that might contain <code>nan</code> values (as defined in numpy).</p>
  
  <p>I would like to understand why this results arise
  and how to implement the correct way.</p>
  
  <p>What I don't understand is why these expressions evaluate to the value they do:</p>
  
  <pre><code>from numpy import nan
  
  nan and True
  &gt;&gt;&gt; True
  # this is wrong.. I would expect to evaluate to nan
  
  True and nan
  &gt;&gt;&gt; nan
  # OK
  
  nan and False
  &gt;&gt;&gt; False
  # OK regardless the value of the first element 
  # the expression should evaluate to False
  
  False and nan
  &gt;&gt;&gt; False
  #ok
  </code></pre>
  
  <p>Similarly for <code>or</code>:</p>
  
  <pre><code>True or nan
  &gt;&gt;&gt; True #OK
  
  nan or True
  &gt;&gt;&gt; nan #wrong the expression is True
  
  False or nan
  &gt;&gt;&gt; nan #OK
  
  nan or False
  &gt;&gt;&gt; nan #OK
  </code></pre>
  
  <p>How can I implement (in an efficient way) the correct boolean functions, handling also <code>nan</code> values?</p>