

def _covariance_matrix_inverse(cov_mat, n_components):
    if (n_components is None):
        return np.linalg.inv(cov_mat)
    else:
        try:
            (s, v, d) = np.linalg.svd(cov_mat)
            s = s[:, :n_components]
            v = v[:n_components]
            d = d[:n_components, :]
            return s.dot(np.diag((1 / v))).dot(d)
        except:
            return np.linalg.inv(cov_mat)

dataset/ETHPy150Open menpo/menpo/menpo/model/gmrf.py _covariance_matrix_inverse/original