def parse_dformat(dformat, check=True):
    """Return `dformat` or raise if it is not 'dense' or 'sparse'"""
    if check and dformat not in ['dense', 'sparse']:
        raise IOError(
            "{} is a bad features format, please choose 'dense' or 'sparse'"
            .format(dformat))
    return dformat
