def clip_range(min_range, max_range, map_shape):
    """
    clips range to stay in map_shape
    :param min_range array(2)[int]: [int, int] min row col range
    :param max_range array(2)[int]: [int, int] max row col range
    :param map_shape array(2)[int]: (int, int) map shape
    :return Tuple[array(2), array(2)]: the min range and max range, clipped.
    """
    clipped_min_range = [max(min_range[0], 0), max(min_range[1], 0)]
    clipped_max_range = [min(max_range[0], map_shape[0]), min(max_range[1], map_shape[1])]
    return clipped_min_range, clipped_max_range