intersect2d

    intersect rows of 2d numpy arrays

    DEPRICATE: use intersect2d in vtool instead

    Args:
        A (ndarray[ndim=2]):
        B (ndarray[ndim=2]):

    Returns:
        tuple: (C, Ax, Bx)

    Example:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_numpy import *  # NOQA
        >>> import utool as ut
        >>> A = np.array([[1, 2, 3], [1, 1, 1]])
        >>> B = np.array([[1, 2, 3], [1, 2, 14]])
        >>> (C, Ax, Bx) = ut.intersect2d(A, B)
        >>> result = str((C, Ax, Bx))
        >>> print(result)
        (array([[1, 2, 3]]), array([0]), array([0]))

def intersect2d(A, B):
    """
    intersect2d

    intersect rows of 2d numpy arrays

    DEPRICATE: use intersect2d in vtool instead

    Args:
        A (ndarray[ndim=2]):
        B (ndarray[ndim=2]):

    Returns:
        tuple: (C, Ax, Bx)

    Example:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_numpy import *  # NOQA
        >>> import utool as ut
        >>> A = np.array([[1, 2, 3], [1, 1, 1]])
        >>> B = np.array([[1, 2, 3], [1, 2, 14]])
        >>> (C, Ax, Bx) = ut.intersect2d(A, B)
        >>> result = str((C, Ax, Bx))
        >>> print(result)
        (array([[1, 2, 3]]), array([0]), array([0]))
    """
    Cset  =  set(tuple(x) for x in A).intersection(set(tuple(x) for x in B))
    Ax = np.array([x for x, item in enumerate(A) if tuple(item) in Cset], dtype=np.int)
    Bx = np.array([x for x, item in enumerate(B) if tuple(item) in Cset], dtype=np.int)
    C = np.array(tuple(Cset))
    return C, Ax, Bx