def _subsample( X, ind):
    """ like X[ind,:] but works in case X has size (n,) """
    if X.ndim == 1:
        y = X[ind]
    elif X.ndim == 2:
        y = X[ind,:]
    else:
        raise ValueError("Expected 1D or 2D array")
    return y