def contains(self, x, y): """ Test whether a set of (x,y) points falls within the region of interest :param x: A list of x points :param y: A list of y points *Returns* A list of True/False values, for whether each (x,y) point falls within the ROI """ if not self.defined(): raise UndefinedROI if not isinstance(x, np.ndarray): x = np.asarray(x) if not isinstance(y, np.ndarray): y = np.asarray(y) result = points_inside_poly(x.flat, y.flat, self.vx, self.vy) good = np.isfinite(x.flat) & np.isfinite(y.flat) result[~good] = False result.shape = x.shape return result
def contains(self, x, y): """Return true/false for each x/y pair. Parameters ---------- x : :class:`numpy.ndarray` Array of x locations y : :class:`numpy.ndarray` Array of y locations Returns ------- :class:`numpy.ndarray` A boolean array, where each element is `True` if the corresponding (x,y) tuple is inside the Roi. Raises ------ UndefinedROI if not defined """ if not self.defined(): raise UndefinedROI if not isinstance(x, np.ndarray): x = np.asarray(x) if not isinstance(y, np.ndarray): y = np.asarray(y) result = points_inside_poly(x, y, self.vx, self.vy) return result