Validate which keypoints are contained inside a given box.
    points: NxKx2
    boxes: Nx4
    output: NxK
978954
def _within_box(points, boxes):
    
    x_within = (points[..., 0] >= boxes[:, 0, None]) & (
        points[..., 0] <= boxes[:, 2, None]
    )
    y_within = (points[..., 1] >= boxes[:, 1, None]) & (
        points[..., 1] <= boxes[:, 3, None]
    )
    return x_within & y_within
1088176
def contains_point?(point)
      return false unless inside_bounding_box?(point)
      c = false
      i = -1
      j = size - 1
      while (i += 1) < size
        if (self[i].y <= point.y && point.y < self[j].y) ||
           (self[j].y <= point.y && point.y < self[i].y)
          if point.x < (self[j].x - self[i].x) * (point.y - self[i].y) / (self[j].y - self[i].y) + self[i].x
            c = !c
          end
        end
        j = i
      end
      c
    end
176529
def _validate(self, writing=True):
        """"""
        if any([box.box_id != 'colr' for box in self.box]):
            msg = ("Colour group boxes can only contain colour specification "
                   "boxes.")
            self._dispatch_validation_error(msg, writing=writing)
701611
def get_bounding_box(self):
        
        if not isinstance(self.ref_cell, Cell):
            return None
        if (self.rotation is None and self.magnification is None and
                self.x_reflection is None):
            key = self
        else:
            key = (self.ref_cell, self.rotation, self.magnification,
                   self.x_reflection)
        deps = self.ref_cell.get_dependencies(True)
        if not (self.ref_cell._bb_valid and
                all(ref._bb_valid for ref in deps) and key in _bounding_boxes):
            for ref in deps:
                ref.get_bounding_box()
            self.ref_cell.get_bounding_box()
            tmp = self.origin
            self.origin = None
            polygons = self.get_polygons()
            self.origin = tmp
            if len(polygons) == 0:
                bb = None
            else:
                all_points = numpy.concatenate(polygons).transpose()
                bb = numpy.array(((all_points[0].min(), all_points[1].min()),
                                  (all_points[0].max(), all_points[1].max())))
            _bounding_boxes[key] = bb
        else:
            bb = _bounding_boxes[key]
        if self.origin is None or bb is None:
            return bb
        else:
            return bb + numpy.array(((self.origin[0], self.origin[1]),
                                     (self.origin[0], self.origin[1])))
18415
public static boolean contains(SpatialComparable box, double[] point) {
    final int dim = box.getDimensionality();
    if(dim != point.length) {
      throw new IllegalArgumentException("This HyperBoundingBox and the given point need same dimensionality");
    }

    for(int i = 0; i < dim; i++) {
      if(box.getMin(i) > point[i] || box.getMax(i) < point[i]) {
        return false;
      }
    }
    return true;
  }
669268
def box(self, x0, y0, width, height):
        
        assert width > 1
        assert height > 1

        width -= 1
        height -= 1

        for x in range(x0, x0 + width):
            self.point(x, y0, "-")
            self.point(x, y0 + height, "-")

        for y in range(y0, y0 + height):
            self.point(x0, y, "|")
            self.point(x0 + width, y, "|")

        self.point(x0, y0, "+")
        self.point(x0 + width, y0, "+")
        self.point(x0, y0 + height, "+")
        self.point(x0 + width, y0 + height, "+")
4558
def _validate_jpx_compatibility(self, boxes, compatibility_list):
        
        JPX_IDS = ['asoc', 'nlst']
        jpx_cl = set(compatibility_list)
        for box in boxes:
            if box.box_id in JPX_IDS:
                if len(set(['jpx ', 'jpxb']).intersection(jpx_cl)) == 0:
                    msg = ("A JPX box requires that either 'jpx ' or 'jpxb' "
                           "be present in the ftype compatibility list.")
                    raise RuntimeError(msg)
            if hasattr(box, 'box') != 0:
                # Same set of checks on any child boxes.
                self._validate_jpx_compatibility(box.box, compatibility_list)
1305139
def check_keypoint(kp, rows, cols):
    """"""
    for name, value, size in zip(['x', 'y'], kp[:2], [cols, rows]):
        if not 0 <= value < size:
            raise ValueError(
                'Expected {name} for keypoint {kp} '
                'to be in the range [0.0, {size}], got {value}.'.format(
                    kp=kp,
                    name=name,
                    value=value,
                    size=size
                )
            )
1285102
def validate(
            self,
            point: Tuple[float, float, float],
            point_num: int,
            pipette_mount) -> str:
        
        _, _, cz = self._driver_to_deck_coords(self._position())
        if self._current_mount != pipette_mount and cz < SAFE_HEIGHT:
            self.move_to_safe_height()

        self._current_mount = pipette_mount
        self._current_point = point_num

        _, _, cz = self._driver_to_deck_coords(self._position())
        if cz < SAFE_HEIGHT:
            self.move_to_safe_height()

        tx, ty, tz = self._deck_to_driver_coords(point)
        if not feature_flags.use_protocol_api_v2():
            self.hardware._driver.move({'X': tx, 'Y': ty})
            self.hardware._driver.move({self._current_mount: tz})
        else:
            pt = types.Point(x=tx, y=ty, z=tz)
            self.hardware.move_to(self._current_mount, pt)
        return 'moved to point {}'.format(point)
856259
function inside(point, vs) {
  // ray-casting algorithm based on
  // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html

  var x = point.x,
    y = point.y;

  var inside = false;
  for (var i = 0, j = vs.length - 1; i < vs.length; j = i++) {
    var xi = vs[i].x,
      yi = vs[i].y;
    var xj = vs[j].x,
      yj = vs[j].y;

    var intersect =
      yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi;
    if (intersect) inside = !inside;
  }

  return inside;
}
572039
def _check_superbox_for_top_levels(self, boxes):
        """"""
        # We are only looking at the boxes contained in a superbox, so if any
        # of the blacklisted boxes show up here, it's an error.
        TOP_LEVEL_ONLY_BOXES = set(['dtbl'])
        box_ids = set([box.box_id for box in boxes])
        intersection = box_ids.intersection(TOP_LEVEL_ONLY_BOXES)
        if len(intersection) > 0:
            msg = "A {0} box cannot be nested in a superbox."
            raise IOError(msg.format(list(intersection)[0]))

        # Recursively check any contained superboxes.
        for box in boxes:
            if hasattr(box, 'box'):
                self._check_superbox_for_top_levels(box.box)
75140
function(point, bbox) {
        return inRange(point[0], bbox[0][0], bbox[1][0])
                && inRange(point[1], bbox[0][1], bbox[1][1]);
        function inRange(val, a, b) {
            return (val - a) * (val - b) <= 0;
        }
    }
732573
def get_outer_bounding_boxes(rectangles):
    
    if len(rectangles) == 0:
        return []
    outer_bboxes = [rectangles[0]]
    for bbox2 in rectangles[1:]:
        overlap_indexes = []
        for i, bbox1 in enumerate(outer_bboxes):  # TODO: optimize this !!
            if doOverlap(bbox1, bbox2):
                overlap_indexes.append(i)
        for i in overlap_indexes:
            bbox2 = mergeBboxes(bbox2, outer_bboxes[i])
        for i in sorted(overlap_indexes, reverse=True):
            del outer_bboxes[i]
        outer_bboxes.append(bbox2)
    return outer_bboxes
1355607
def get_bounding_box(points):
    
    assert len(points) > 0, "At least one point has to be given."
    min_x, max_x = points[0]['x'], points[0]['x']
    min_y, max_y = points[0]['y'], points[0]['y']
    for point in points:
        min_x, max_x = min(min_x, point['x']), max(max_x, point['x'])
        min_y, max_y = min(min_y, point['y']), max(max_y, point['y'])
    p1 = Point(min_x, min_y)
    p2 = Point(max_x, max_y)
    return BoundingBox(p1, p2)
780364
def _validate_top_level(self, boxes):
        """"""
        # Add the counts in the superboxes.
        for box in boxes:
            if hasattr(box, 'box'):
                self._check_superbox_for_top_levels(box.box)

        count = self._collect_box_count(boxes)

        # If there is one data reference box, then there must also be one ftbl.
        if 'dtbl' in count and 'ftbl' not in count:
            msg = ('The presence of a data reference box requires the '
                   'presence of a fragment table box as well.')
            raise IOError(msg)
1222387
def contains(self, point):
        

        y2 = point.y * point.y
        x3 = point.x * point.x * point.x
        return (y2 - (x3 + self.a * point.x + self.b)) % self.p == 0
18286
def get_bounding_box(self):
        
        if len(self.elements) == 0:
            return None
        if not (self._bb_valid and
                all(ref._bb_valid for ref in self.get_dependencies(True))):
            bb = numpy.array(((1e300, 1e300), (-1e300, -1e300)))
            all_polygons = []
            for element in self.elements:
                if isinstance(element, PolygonSet):
                    all_polygons.extend(element.polygons)
                elif isinstance(element, CellReference) or isinstance(
                        element, CellArray):
                    element_bb = element.get_bounding_box()
                    if element_bb is not None:
                        bb[0, 0] = min(bb[0, 0], element_bb[0, 0])
                        bb[0, 1] = min(bb[0, 1], element_bb[0, 1])
                        bb[1, 0] = max(bb[1, 0], element_bb[1, 0])
                        bb[1, 1] = max(bb[1, 1], element_bb[1, 1])
            if len(all_polygons) > 0:
                all_points = numpy.concatenate(all_polygons).transpose()
                bb[0, 0] = min(bb[0, 0], all_points[0].min())
                bb[0, 1] = min(bb[0, 1], all_points[1].min())
                bb[1, 0] = max(bb[1, 0], all_points[0].max())
                bb[1, 1] = max(bb[1, 1], all_points[1].max())
            self._bb_valid = True
            _bounding_boxes[self] = bb
        return _bounding_boxes[self]