title: (Python) Find the indices of the values in two arrays that are equal to the values in two other arrays
body: <p>I have the following 4 arrays and I want to get the indices of the values that are equal in the arrays A and X corresponding to the values in the same position in B and Y. So for the following example,</p>
  <pre><code>    import numpy as np
      A = np.asarray([400.5, 100,  700,   200,  15, 900])
      B = np.asarray([500.5, 200,  500, 600.5,   8, 999])
      X = np.asarray([400.5, 700,  100,   300,  15, 555, 900])
      Y = np.asarray([500.5, 500,600.5,   100,   8, 555, 999])
  </code></pre>
  <p>I want to get two arrays with the indices:</p>
  <h3>indAB = [0 2 4 5]</h3>
  <ul>
  <li>0 because 400.5 and 500.5 in A&amp;B are also in X&amp;Y in the position 0</li>
  <li>2 because 700 and 500 in A&amp;B are also in X&amp;Y in the position 2</li>
  <li>4 because 15 and 8 in A&amp;B are also in X&amp;Y in the position 4</li>
  <li>5 because 900 and 999 in A&amp;B are also in X&amp;Y in the position 5</li>
  </ul>
  <h3>indXY = [0 1 4 6]</h3>
  <ul>
  <li>0, 1, 4, and 6 are found similar to indAB but with respect to X&amp;Y instead.</li>
  </ul>
  <p>where indAB are the indices of the values in A and B that are equal to the values in X and Y and indXY are the indices of the values in X and Y that are equal to the values in A and B.</p>
  <p>This is my attempt so far:</p>
  <pre><code>    def indices(a,b):
          setb = set(b)
          ind = [i for i, x in enumerate(a) if x in setb]
          return ind
  
      iA = np.asarray(indices(A,X))
      iB = np.asarray(indices(X,A))
      iX = np.asarray(indices(B,Y))
      iY = np.asarray(indices(Y,B))
  
      def CommonIndices(a,b):
          return np.asarray(list(set(a) &amp; set(b)))
  
      indAB = CommonIndices(iA,iX)
      indXY = CommonIndices(iB,iY)
  
      print(indAB) # returns = [0 2 4 5]
      print(indXY) # returns = [0 1 2 4 6]
  </code></pre>
  <p>I keep getting [0 1 2 4 6] for indXY which is incorrect. 2 is not supposed to be included because even though 600.5 is in Y and B, 200 and 100 in A and B (respectively) are not equal.</p>
  <p>I would be very grateful if someone could offer a solution to this. Many thanks!</p>