nodes: 0, module; 1, function_definition; 2, function_name:equalspairs; 3, parameters; 4, block; 5, identifier:X; 6, identifier:Y; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, expression_statement; 17, return_statement; 18, comment:"""
      Indices of elements in a sorted numpy array equal to those in another.
  
      Given numpy array `X` and sorted numpy array `Y`, determine the indices in 
      Y equal to indices in X.
  
      Returns `[A,B]` where `A` and `B` are numpy arrays of indices in `X` such 
      that::
  
              Y[A[i]:B[i]] = Y[Y == X[i]]`
  
      `A[i] = B[i] = 0` if `X[i]` is not in `Y`.
  
      **Parameters**
  
              **X** :  numpy array
  
                      Numpy array to compare to the sorted numpy array `Y`.
  
              **Y** :  numpy array
  
                      Sorted numpy array.  Determine the indices of elements of 
                      `Y` equal to those in numpy array `X`.
  
      **Returns**
  
              **A** :  numpy array
  
                      List of indices in `Y`, `len(A) = len(Y)`.
  
              **B** :  numpy array
  
                      List of indices in `Y`, `len(B) = len(Y)`.
  
      **See Also:**
  
              :func:`tabular.fast.recarrayequalspairs`
  
      """; 19, assignment; 20, assignment; 21, assignment; 22, assignment; 23, assignment; 24, assignment; 25, assignment; 26, assignment; 27, assignment; 28, list; 29, identifier:T; 30, call; 31, identifier:R; 32, subscript; 33, identifier:R; 34, call; 35, identifier:M; 36, subscript; 37, identifier:D; 38, call; 39, identifier:T; 40, call; 41, identifier:M; 42, call; 43, identifier:A; 44, binary_operator:(T[D] == X) * D; 45, identifier:B; 46, binary_operator:(T[D] == X) * (M[D] + 1); 47, identifier:A; 48, identifier:B; 49, attribute; 50, argument_list; 51, call; 52, integer:0; 53, attribute; 54, argument_list; 55, identifier:R; 56, call; 57, attribute; 58, argument_list; 59, attribute; 60, argument_list; 61, attribute; 62, argument_list; 63, parenthesized_expression; 64, identifier:D; 65, parenthesized_expression; 66, parenthesized_expression; 67, identifier:Y; 68, identifier:copy; 69, attribute; 70, argument_list; 71, identifier:np; 72, identifier:append; 73, identifier:R; 74, call; 75, attribute; 76, argument_list; 77, identifier:T; 78, identifier:searchsorted; 79, identifier:X; 80, identifier:np; 81, identifier:append; 82, identifier:T; 83, call; 84, identifier:np; 85, identifier:append; 86, identifier:M; 87, call; 88, comparison_operator:T[D] == X; 89, comparison_operator:T[D] == X; 90, binary_operator:M[D] + 1; 91, parenthesized_expression; 92, identifier:nonzero; 93, attribute; 94, argument_list; 95, identifier:R; 96, identifier:searchsorted; 97, call; 98, attribute; 99, argument_list; 100, attribute; 101, argument_list; 102, subscript; 103, identifier:X; 104, subscript; 105, identifier:X; 106, subscript; 107, integer:1; 108, comparison_operator:T[1:] != T[:-1]; 109, identifier:np; 110, identifier:array; 111, list; 112, identifier:range; 113, argument_list; 114, identifier:np; 115, identifier:array; 116, list; 117, identifier:np; 118, identifier:array; 119, list; 120, identifier:T; 121, identifier:D; 122, identifier:T; 123, identifier:D; 124, identifier:M; 125, identifier:D; 126, subscript; 127, subscript; 128, binary_operator:len(T)-1; 129, call; 130, integer:0; 131, integer:0; 132, identifier:T; 133, slice; 134, identifier:T; 135, slice; 136, call; 137, integer:1; 138, identifier:len; 139, argument_list; 140, integer:1; 141, unary_operator; 142, identifier:len; 143, argument_list; 144, identifier:T; 145, integer:1; 146, identifier:T
code: def equalspairs(X, Y):
      """
      Indices of elements in a sorted numpy array equal to those in another.
  
      Given numpy array `X` and sorted numpy array `Y`, determine the indices in 
      Y equal to indices in X.
  
      Returns `[A,B]` where `A` and `B` are numpy arrays of indices in `X` such 
      that::
  
              Y[A[i]:B[i]] = Y[Y == X[i]]`
  
      `A[i] = B[i] = 0` if `X[i]` is not in `Y`.
  
      **Parameters**
  
              **X** :  numpy array
  
                      Numpy array to compare to the sorted numpy array `Y`.
  
              **Y** :  numpy array
  
                      Sorted numpy array.  Determine the indices of elements of 
                      `Y` equal to those in numpy array `X`.
  
      **Returns**
  
              **A** :  numpy array
  
                      List of indices in `Y`, `len(A) = len(Y)`.
  
              **B** :  numpy array
  
                      List of indices in `Y`, `len(B) = len(Y)`.
  
      **See Also:**
  
              :func:`tabular.fast.recarrayequalspairs`
  
      """
      T = Y.copy()
      R = (T[1:] != T[:-1]).nonzero()[0]
      R = np.append(R,np.array([len(T)-1]))
      M = R[R.searchsorted(range(len(T)))]
      D = T.searchsorted(X)
      T = np.append(T,np.array([0]))
      M = np.append(M,np.array([0]))
      A = (T[D] == X) * D
      B = (T[D] == X) * (M[D] + 1)
      return [A,B]