title: Testing if rows in a numpy array are the same as a given row or different by each element
body: <p>This is related to my earlier question: <a href="https://stackoverflow.com/questions/22605554/elementwise-logical-comparison-of-numpy-arrays/22605851#22605851">Elementwise logical comparison of numpy arrays</a></p>
  
  <p>I have two numpy arrays of random integers</p>
  
  <pre><code>A=np.random.randint(Q,size=(N,M))
  B=np.random.randint(Q,size=(1,M))
  </code></pre>
  
  <p>I need to test if any of the rows in A have more than 0 and less than M common elements elementwise with B.</p>
  
  <p>For example if</p>
  
  <pre><code>A=np.array([[2,0],[0,1],[1,2]])
  B=np.array([1,0])
  </code></pre>
  
  <p>I would expect <code>True</code> since <code>[1,0]</code> and <code>[1,2]</code> share more than 0 and less than 2 elements elemenwise.</p>
  
  <p>On the other hand if</p>
  
  <pre><code>B=np.array([2,0])
  </code></pre>
  
  <p>I would expect <code>False</code> since there are only rows which chare 2 or 0 elements elementwise</p>
  
  <p>At the moment my approach is:</p>
  
  <pre><code>c=np.where((A[:]==B))[0]
  n=np.bincount(c)
  ((n==0)+(n==2)).all()
  </code></pre>
  
  <p>To me this seems like a convoluted way of testing this and I was wondering if there was a more natural way that I'm missing.</p>