def in_region(obj, region, entire=True):
    """Test if an object is in a region.

    Args:
        obj (tuple or BBox): Object bounding box
            (xmin, xmax, ymin, ymax) or point (x, y).
        region (tuple or BBox): Region (xmin, xmax, ymin, ymax).
        entire (bool): Object is entirely contained in region.

    Returns:
        bool: Result
    """
    if len(obj) == 4:
        if entire:
            result = region[0] <= obj[0] <= obj[1] <= region[1] and region[2
                ] <= obj[2] <= obj[3] <= region[3]
        else:
            result = region[0] <= obj[0] <= region[1] or region[0] <= obj[1
                ] <= region[1] or region[2] <= obj[2] <= region[3] or region[2
                ] <= obj[3] <= region[3]
    else:
        assert len(obj) == 2, 'Invalid point or bounding box.'
        result = region[0] <= obj[0] <= region[1] and region[2] <= obj[1
            ] <= region[3]
    return result
