def boolean_rows(a, b, operation=np.intersect1d):
    """
    Find the rows in two arrays which occur in both rows.

    Parameters
    ---------
    a: (n, d) int
        Array with row vectors
    b: (m, d) int
        Array with row vectors
    operation : function
        Numpy boolean set operation function:
          -np.intersect1d
          -np.setdiff1d

    Returns
    --------
    shared: (p, d) array containing rows in both a and b
    """
    a = np.asanyarray(a, dtype=np.int64)
    b = np.asanyarray(b, dtype=np.int64)

    av = a.view([('', a.dtype)] * a.shape[1]).ravel()
    bv = b.view([('', b.dtype)] * b.shape[1]).ravel()
    shared = operation(av, bv).view(a.dtype).reshape(-1, a.shape[1])

    return shared
def boolean_rows ( a , b , operation = np . intersect1d ) : a = np . asanyarray ( a , dtype = np . int64 ) b = np . asanyarray ( b , dtype = np . int64 ) av = a . view ( [ ( '' , a . dtype ) ] * a . shape [ 1 ] ) . ravel ( ) bv = b . view ( [ ( '' , b . dtype ) ] * b . shape [ 1 ] ) . ravel ( ) shared = operation ( av , bv ) . view ( a . dtype ) . reshape ( - 1 , a . shape [ 1 ] ) return shared
Find the rows in two arrays which occur in both rows.

    Parameters
    ---------
    a: (n, d) int
        Array with row vectors
    b: (m, d) int
        Array with row vectors
    operation : function
        Numpy boolean set operation function:
          -np.intersect1d
          -np.setdiff1d

    Returns
    --------
    shared: (p, d) array containing rows in both a and b