Check if bbox boundaries are in range 0, 1 and minimums are lesser then maximums
437355
def check_bbox(bbox):
    """"""
    for name, value in zip(['x_min', 'y_min', 'x_max', 'y_max'], bbox[:4]):
        if not 0 <= value <= 1:
            raise ValueError(
                'Expected {name} for bbox {bbox} '
                'to be in the range [0.0, 1.0], got {value}.'.format(
                    bbox=bbox,
                    name=name,
                    value=value,
                )
            )
    x_min, y_min, x_max, y_max = bbox[:4]
    if x_max <= x_min:
        raise ValueError('x_max is less than or equal to x_min for bbox {bbox}.'.format(
            bbox=bbox,
        ))
    if y_max <= y_min:
        raise ValueError('y_max is less than or equal to y_min for bbox {bbox}.'.format(
            bbox=bbox,
        ))
79090
def _combine_bounds(bbox1, bbox2):
    """"""
    WORLD = {'west': -180, 'south': -85.1, 'east': 180, 'north': 85.1}
    ALL_KEYS = set(WORLD.keys())

    def dict_all_nones(bbox_dict):
        """Returns True if all dict values are None"""
        return all(v is None for v in bbox_dict.values())

    # if neither are defined, use the world
    if not bbox1 and not bbox2:
        return WORLD
    # if all nones, use the world
    if dict_all_nones(bbox1) and dict_all_nones(bbox2):
        return WORLD

    assert ALL_KEYS == set(bbox1.keys()) and ALL_KEYS == set(bbox2.keys()),\
        'Input bounding boxes must have the same dictionary keys'
    # create dict with cardinal directions and None-valued keys
    outbbox = dict.fromkeys(['west', 'south', 'east', 'north'])

    def conv2nan(val):
        """convert Nones to np.nans"""
        return np.nan if val is None else val

    # set values and/or defaults
    for coord in ('north', 'east'):
        outbbox[coord] = np.nanmax([
                conv2nan(bbox1[coord]),
                conv2nan(bbox2[coord])
            ])
    for coord in ('south', 'west'):
        outbbox[coord] = np.nanmin([
                conv2nan(bbox1[coord]),
                conv2nan(bbox2[coord])
            ])

    return outbbox
706374
def checkrange(bch, fieldname):
    """"""
    fieldvalue = bch[fieldname]
    therange = bch.getrange(fieldname)
    if therange['maximum'] != None:
        if fieldvalue > therange['maximum']:
            astr = "Value %s is not less or equal to the 'maximum' of %s"
            astr = astr % (fieldvalue, therange['maximum'])
            raise RangeError(astr)
    if therange['minimum'] != None:
        if fieldvalue < therange['minimum']:
            astr = "Value %s is not greater or equal to the 'minimum' of %s"
            astr = astr % (fieldvalue, therange['minimum'])
            raise RangeError(astr)
    if therange['maximum<'] != None:
        if fieldvalue >= therange['maximum<']:
            astr = "Value %s is not less than the 'maximum<' of %s"
            astr = astr % (fieldvalue, therange['maximum<'])
            raise RangeError(astr)
    if  therange['minimum>'] != None:
        if fieldvalue <= therange['minimum>']:
            astr = "Value %s is not greater than the 'minimum>' of %s"
            astr = astr % (fieldvalue, therange['minimum>'])
            raise RangeError(astr)
    return fieldvalue
    """get the idd dict for this field
    Will return {} if the fieldname does not exist"""
83788
def max_or_none(val1, val2):
    """"""
    return max(val1, val2, key=lambda x: -sys.maxint if x is None else x)
303434
private int[] checkBoundaries(int[] minMax, int[] dim) {
        if (minMax[0] < 0) {
            minMax[0] = 0;
        }
        if (minMax[1] > dim[0]) {
            minMax[1] = dim[0];
        }
        if (minMax[2] < 0) {
            minMax[2] = 0;
        }
        if (minMax[3] > dim[1]) {
            minMax[3] = dim[1];
        }
        if (minMax[4] < 0) {
            minMax[4] = 0;
        }
        if (minMax[5] > dim[2]) {
            minMax[5] = dim[2];
        }
        return minMax;
    }
622974
def within_bbox(self, bbox):
        
        min_lon, min_lat, max_lon, max_lat = bbox
        lons, lats = self.array['lon'], self.array['lat']
        if cross_idl(lons.min(), lons.max()) or cross_idl(min_lon, max_lon):
            lons = lons % 360
            min_lon, max_lon = min_lon % 360, max_lon % 360
        mask = (min_lon < lons) * (lons < max_lon) * \
               (min_lat < lats) * (lats < max_lat)
        return mask.nonzero()[0]
441932
function (bbox) {
        var min = this.min;
        var max = this.max;
        vec3.min(min.array, min.array, bbox.min.array);
        vec3.max(max.array, max.array, bbox.max.array);
        min._dirty = true;
        max._dirty = true;
        return this;
    }
671669
function check_bounds(buf, offset, len) {
    if (offset < 0 || offset + len > buf.length) {
        throw new RangeError("Index out of range");
    }
}
644038
function rangesIntersect(rangeA, rangeB) {
  return rangeA.compareBoundaryPoints(Range.END_TO_START, rangeB) === -1 &&
    rangeA.compareBoundaryPoints(Range.START_TO_END, rangeB) === 1
}
1247567
def check(self, value):
        
        if self._inclusive:
            return False if self._min <= value <= self._max else True
        else:
            return False if value > self._max or value < self._min else True
714116
def _check_area_bbox(self):
        
        for coord in self.area_bbox:
            if abs(coord) > self.POP_WEB_MAX:
                raise ValueError('OsmTileSplitter only works for areas which have latitude in interval '
                                 '(-85.0511, 85.0511)')
979767
function BBox(left, top, width, height) {
      var s;

      if (left == null) {
        left = 0;
      }
      if (top == null) {
        top = 0;
      }
      if (width == null) {
        width = null;
      }
      if (height == null) {
        height = null;
      }
      s = this;
      if (width === null) {
        s.xmin = Number.MAX_VALUE;
        s.xmax = Number.MAX_VALUE * -1;
      } else {
        s.xmin = s.left = left;
        s.xmax = s.right = left + width;
        s.width = width;
      }
      if (height === null) {
        s.ymin = Number.MAX_VALUE;
        s.ymax = Number.MAX_VALUE * -1;
      } else {
        s.ymin = s.top = top;
        s.ymax = s.bottom = height + top;
        s.height = height;
      }
      return;
    }
1328981
def is_bbox_not_intersecting(self, other):
        """"""

        self_x_min, self_x_max, self_y_min, self_y_max = self.get_bbox()
        other_x_min, other_x_max, other_y_min, other_y_max = other.get_bbox()

        return \
            self_x_min > other_x_max or \
            other_x_min > self_x_max or \
            self_y_min > other_y_max or \
            other_y_min > self_y_max
1075067
def is_valid_boundaries(self, boundaries):
        """"""
        if boundaries is not None:
            min_ = boundaries[0]
            for value in boundaries:
                if value < min_:
                    return False
                else:
                    min_ = value
            return True
        return False
642199
def within_range(range1, range2):
    """"""
    range1 = [r if isfinite(r) else None for r in range1]
    range2 = [r if isfinite(r) else None for r in range2]
    return ((range1[0] is None or range2[0] is None or range1[0] >= range2[0]) and
            (range1[1] is None or range2[1] is None or range1[1] <= range2[1]))
245256
def interval_overlap(a, b, x, y):
    """"""
    if b <= x or a >= y:
        return 0
    elif x <= a <= y:
        return min(b, y) - a
    elif x <= b <= y:
        return b - max(a, x)
    elif a >= x and b <= y:
        return b - a
    else:
        assert False
1015547
def bbox(self):
        """"""
        xmin = min(self.start.real, self.end.real)
        xmax = max(self.start.real, self.end.real)
        ymin = min(self.start.imag, self.end.imag)
        ymax = max(self.start.imag, self.end.imag)
        return xmin, xmax, ymin, ymax