def _check_Y(Y, mlfm):
    """ Backwards compatibility for nonvectorised Y.
    """
    if len(Y.shape) == 1:
        return Y
    elif len(Y.shape) == 2:
        ncol = Y.shape[1]
        nrow = Y.shape[0]
        if ncol == mlfm.dim.K and nrow == mlfm._Ndata:
            return Y.T.ravel()
        elif nrow == mlfm._Ndata * mlfm.dim.K:
            return Y
        else:
            raise ValueError('Bad shape for data Y.')
    else:
        msg = 'Shape of Y is not compatible.'
        raise ValueError(msg)
