def scipy_cdist(**kwargs):
    """
    Returns a wrapper of `scipy.spatial.distance.cdist`.

    P and Q are arrays of either dimension 1 or 2.

    If P is a matrix, then angles are computed wrt the rows of P. If Q
    is a matrix, then angles are computed wrt the columns of Q.
    """
    from scipy.spatial.distance import cdist

    def dist_fn(P, Q):

        P = P.astype(np.float)
        Q = Q.astype(np.float)

        if 2 < P.ndim:
            P = P.reshape((1,P.size))
        if Q.ndim < 2:
            Q = Q.reshape((Q.size,1))
            
        out = cdist(P, Q.T, **kwargs)

        out = np.squeeze(out)
        if out.ndim == 0:
            return out[()]
        return out

    return dist_fn


#
# Functions for computing angular distances between points projected
# onto an n-sphere
#
dataset/ETHPy150Open inpho/vsm/vsm/spatial.py/scipy_cdist/swapped operands of `<`