import logging


def image_sanity_fail(image, shape, description):
    """
    Sanity check on images: training and testing; shape needs to match.
    description affects the logging, on failure.
    """
    if image is None:
        logging.error("{} : image is None".format(description))
        return True
    elif image.shape != shape:
        logging.error("{} : shape is {}, (expecting {})".format(
            description, repr(image.shape), repr(shape)))
        return True
    else:
        return False