def _check_2d_shape(X):
    """    Check shape of array or sparse matrix.

    Assure that X is always 2D: Unlike numpy we always deal with 2D arrays.
    """
    if X.dtype.names is None and len(X.shape) != 2:
        raise ValueError(
            f'X needs to be 2-dimensional, not {len(X.shape)}-dimensional.')
