title: python tilde unary operator as negation numpy bool array
body: <p>Should be a simple question, but I'm unable to find an answer anywhere. The <code>~</code> operator in python is a documented as a bitwise inversion operator.  Fine. I have noticed seemingly schizophrenic behavior though, to wit:</p>
  
  <pre><code>~True -&gt; -2
  ~1 -&gt; -2
  ~False -&gt; -1
  ~0 -&gt; -1
  ~numpy.array([True,False],dtype=int) -&gt; array([-2,-1])
  ~numpy.array([True,False],dtype=bool) -&gt; array([False,True])
  </code></pre>
  
  <p>In the first 4 examples, I can see that python is implementing (as documented) <code>~x = -(x+1)</code>, with the input treated as an int <em>even if it's boolean</em>. Hence, for a scalar boolean, <code>~</code> is not treated as a logical negation. Not that the behavior is identical on a numpy array defined with boolean values by with an int type.</p>
  
  <p>Why does <code>~</code> then work as a logical negation operator on a boolean array (Also notice: <code>~numpy.isfinite(numpy.inf) -&gt; True</code>?)?</p>
  
  <p>It is extremely annoying that I must use <code>not()</code> on a scalar, but <code>not()</code> won't work to negate an array. Then for an array, I must use <code>~</code>, but <code>~</code> won't work to negate a scalar...</p>