Return a list of rectangular areas that we should avoid while laying out a bubble for the
specified speaker.
776550
protected List<Shape> getAvoidList (Name speaker)
    {
        List<Shape> avoid = Lists.newArrayList();
        if (_provider == null) {
            return avoid;
        }

        // for now we don't accept low-priority avoids
        _provider.getAvoidables(speaker, avoid, null);

        // add the existing chatbub non-tail areas from other speakers
        for (BubbleGlyph bub : _bubbles) {
            if (!bub.isSpeaker(speaker)) {
                avoid.add(bub.getBubbleTerritory());
            }
        }

        return avoid;
    }
148942
protected void selectBoundaryCorners() {
		List<Point2D_F64> layout = detector.getLayout();

		Polygon2D_F64 hull = new Polygon2D_F64();
		UtilPolygons2D_F64.convexHull(layout,hull);
		UtilPolygons2D_F64.removeAlmostParallel(hull,0.02);

		boundaryIndexes = new int[hull.size()];
		for (int i = 0; i < hull.size(); i++) {
			Point2D_F64 h = hull.get(i);
			boolean matched = false;
			for (int j = 0; j < layout.size(); j++) {
				if( h.isIdentical(layout.get(j),1e-6)) {
					matched = true;
					boundaryIndexes[i] = j;
					break;
				}
			}
			if( !matched )
				throw new RuntimeException("Bug!");
		}

	}
410708
def mask2spans(mask, index=None):
    """"""
    index = list(range(len(mask))) if index is None else index

    mask = pd.Series(mask)
    mask = mask.astype(int).fillna(0).diff().fillna(0)
    starts = list(index[mask > 0])
    stops = list(index[mask < 0])
    if len(stops) == len(starts) - 1:
        stops += [index.values[-1]]
    spans = join_spans(join_spans(zip(starts, stops)))
    return spans
1093729
def cleanup(arg):
    """"""
    arg = numpy.asarray(arg)
    if len(arg.shape) <= 1:
        arg = arg.reshape(arg.size, 1)
    elif len(arg.shape) > 2:
        raise ValueError("shapes must be smaller than 3")
    return arg
481603
def exceptlist(self, channel):
        
        with self.lock:
            self.is_in_channel(channel)

            self.send('MODE %s e' % channel)
            excepts = []

            while self.readable():
                msg = self._recv(expected_replies=('348', '349'))

                if msg[0] == '348':
                    exceptmask, who, timestamp = msg[2].split()[1:]
                    excepts.append((self._from_(exceptmask), who, \
                                    self._m_time.localtime(int(timestamp))))
                elif msg[0] == '349':
                    break

            return excepts
439922
def slice(self, key):
        
        if not self.all_same_area:
            raise RuntimeError("'Scene' has different areas and cannot "
                               "be usefully sliced.")
        # slice
        new_scn = self.copy()
        new_scn.wishlist = self.wishlist
        for area, dataset_ids in self.iter_by_area():
            if area is not None:
                # assume dimensions for area are y and x
                one_ds = self[dataset_ids[0]]
                area_key = tuple(sl for dim, sl in zip(one_ds.dims, key) if dim in ['y', 'x'])
                new_area = area[area_key]
            else:
                new_area = None
            new_scn._slice_datasets(dataset_ids, key, new_area)
        return new_scn
372559
def segmentation_to_mask(polys, height, width):
    
    polys = [p.flatten().tolist() for p in polys]
    assert len(polys) > 0, "Polygons are empty!"

    import pycocotools.mask as cocomask
    rles = cocomask.frPyObjects(polys, height, width)
    rle = cocomask.merge(rles)
    return cocomask.decode(rle)
53723
def _list_rjust(self, L, width, fillchar=0):
        ''''''
        length = max(0, width - len(L))
        return [fillchar]*length + L
874688
def filter_boxes_inside_shape(boxes, shape):
    
    assert boxes.ndim == 2, boxes.shape
    assert len(shape) == 2, shape
    h, w = shape
    indices = np.where(
        (boxes[:, 0] >= 0) &
        (boxes[:, 1] >= 0) &
        (boxes[:, 2] <= w) &
        (boxes[:, 3] <= h))[0]
    return indices, boxes[indices, :]
687608
def tileslist(self, bbox, zoomlevels):
        
        proj = GoogleProjection(self.tile_size, zoomlevels, self.tile_scheme)
        return proj.tileslist(bbox)
693684
def _mask_space(self, data):
        """"""
        geomask = get_geostationary_mask(area=self.area)
        return data.where(geomask)
598837
protected Shape getTail (int type, Rectangle r, Point speaker)
    {
        // emotes don't actually have tails
        if (ChatLogic.modeOf(type) == ChatLogic.EMOTE) {
            return new Area(); // empty shape
        }

        int midx = r.x + (r.width / 2);
        int midy = r.y + (r.height / 2);

        // we actually want to start about SPEAKER_DISTANCE away from the
        // speaker
        int xx = speaker.x - midx;
        int yy = speaker.y - midy;
        float dist = (float) Math.sqrt(xx * xx + yy * yy);
        float perc = (dist - SPEAKER_DISTANCE) / dist;

        if (ChatLogic.modeOf(type) == ChatLogic.THINK) {
            int steps = Math.max((int) (dist / SPEAKER_DISTANCE), 2);
            float step = perc / steps;
            Area a = new Area();
            for (int ii=0; ii < steps; ii++, perc -= step) {
                int radius = Math.min(SPEAKER_DISTANCE / 2 - 1, ii + 2);
                a.add(new Area(new Ellipse2D.Float(
                  (int) ((1 - perc) * midx + perc * speaker.x) + perc * radius,
                  (int) ((1 - perc) * midy + perc * speaker.y) + perc * radius,
                  radius * 2, radius * 2)));
            }

            return a;
        }

        // ELSE draw a triangular tail shape
        Polygon p = new Polygon();
        p.addPoint((int) ((1 - perc) * midx + perc * speaker.x),
                   (int) ((1 - perc) * midy + perc * speaker.y));

        if (Math.abs(speaker.x - midx) > Math.abs(speaker.y - midy)) {
            int x;
            if (midx > speaker.x) {
                x = r.x + PAD;
            } else {
                x = r.x + r.width - PAD;
            }
            p.addPoint(x, midy - (TAIL_WIDTH / 2));
            p.addPoint(x, midy + (TAIL_WIDTH / 2));

        } else {
            int y;
            if (midy > speaker.y) {
                y = r.y + PAD;
            } else {
                y = r.y + r.height - PAD;
            }
            p.addPoint(midx - (TAIL_WIDTH / 2), y);
            p.addPoint(midx + (TAIL_WIDTH / 2), y);
        }

        return p;
    }
1292109
def _rectangular(n):
    """"""
    for i in n:
        if len(i) != len(n[0]):
            return False
    return True
1151877
function fitPositionIntoSafeArea(position, layouts) {
    var windowLayout = layouts.windowLayout,
        safeAreaLayout = layouts.safeAreaLayout,
        optionsLayout = layouts.optionsLayout;

    if (!safeAreaLayout) {
      return position;
    }

    var saX = safeAreaLayout.x,
        saY = safeAreaLayout.y,
        saHeight = safeAreaLayout.height,
        saWidth = safeAreaLayout.width;
    var oHeight = optionsLayout.height,
        oWidth = optionsLayout.width;
    var wWidth = windowLayout.width;
    var top = position.top,
        left = position.left,
        right = position.right;
    top = fit(top, oHeight, saY, saY + saHeight);
    left = fit(left, oWidth, saX, saX + saWidth);
    right = fit(right, oWidth, wWidth - saX - saWidth, saX);
    return {
      top: top,
      left: left,
      right: right
    };
  }
273632
def overlap(r1: 'Rectangle', r2: 'Rectangle'):
        
        h_overlaps = (r1.left <= r2.right) and (r1.right >= r2.left)
        v_overlaps = (r1.bottom >= r2.top) and (r1.top <= r2.bottom)
        return h_overlaps and v_overlaps
1301491
def nonKeyVisibleCols(self):
        ''
        return [c for c in self.columns if not c.hidden and c not in self.keyCols]
417706
def lowPassFilter(self, threshold):
        '''
        
        '''
        if not threshold:
            return
        rows, cols = self.img.shape
        tx = int(cols * threshold * 0.25)
        ty = int(rows * threshold * 0.25)
        # upper side
        self.fshift[rows - tx:rows, :] = 0
        # lower side
        self.fshift[0:tx, :] = 0
        # left side
        self.fshift[:, 0:ty] = 0
        # right side
        self.fshift[:, cols - ty:cols] = 0