def check_bounds(bounds):
    """
    Check a bounds array is correct, raise ValueError if not

    Parameters:
        bounds - the bounds array to check. Of form (minx, miny, maxx, maxy)
            or (left, bottom, right, top).

    Returns:
        the bounds array, if valid
    """
    if not ((bounds[0] <= bounds[2]) and (bounds[1] <= bounds[3])):
        raise ValueError('Bounds should be (minx, miny, maxx, maxy)')
    return bounds