Find a region of the given size.
192993
private Region findRegion(int size, Packing packing) {
    validate(!VALIDATING || Integer.bitCount(size) == 1);

    Node<Region> currentNode = getRoot();
    Region currentRegion = currentNode.getPayload();
    if (currentRegion == null || (currentRegion.available() & size) == 0) {
      //no region big enough for us...
      return null;
    } else {
      while (true) {
        Node<Region> prefered = packing.prefered(currentNode);
        Region preferedRegion = prefered.getPayload();
        if (preferedRegion != null && (preferedRegion.available() & size) != 0) {
          currentNode = prefered;
          currentRegion = preferedRegion;
        } else if ((currentRegion.availableHere() & size) != 0) {
          return packing.slice(currentRegion, size);
        } else {
          Node<Region> fallback = packing.fallback(currentNode);
          Region fallbackRegion = fallback.getPayload();
          if (fallbackRegion != null && (fallbackRegion.available() & size) != 0) {
            currentNode = fallback;
            currentRegion = fallbackRegion;
          } else {
            throw new AssertionError();
          }
        }
      }
    }
  }
584828
def get_region (self, rs,cs, re,ce):
        '''
        '''

        rs = constrain (rs, 1, self.rows)
        re = constrain (re, 1, self.rows)
        cs = constrain (cs, 1, self.cols)
        ce = constrain (ce, 1, self.cols)
        if rs > re:
            rs, re = re, rs
        if cs > ce:
            cs, ce = ce, cs
        sc = []
        for r in range (rs, re+1):
            line = u''
            for c in range (cs, ce + 1):
                ch = self.get_abs (r,c)
                line = line + ch
            sc.append (line)
        return sc
656500
public static AreaL area(final AreaSizeL size)
  {
    Objects.requireNonNull(size, "Size");
    return AreaL.of(0L, size.sizeX(), 0L, size.sizeY());
  }
492092
def get_area_extent(self, size, offsets, factors, platform_height):
        """"""
        nlines, ncols = size
        h = platform_height

        # count starts at 1
        cols = 1 - 0.5
        lines = 1 - 0.5
        ll_x, ll_y = self.get_xy_from_linecol(lines, cols, offsets, factors)

        cols += ncols
        lines += nlines
        ur_x, ur_y = self.get_xy_from_linecol(lines, cols, offsets, factors)

        return (np.deg2rad(ll_x) * h, np.deg2rad(ll_y) * h,
                np.deg2rad(ur_x) * h, np.deg2rad(ur_y) * h)
142198
def within(self, region):
        
        mask = numpy.array([
            geometry.Point(rec['lon'], rec['lat']).within(region)
            for rec in self.array])
        return self.filter(mask)
131686
def find(self, start, end):
        """"""
        if self.intervals and not end < self.intervals[0].start:
            overlapping = [i for i in self.intervals if i.end >= start
                                                    and i.start <= end]
        else:
            overlapping = []

        if self.left and start <= self.center:
            overlapping += self.left.find(start, end)

        if self.right and end >= self.center:
            overlapping += self.right.find(start, end)

        return overlapping
802485
def get_flash_region(self, offset, length):
        
        return self._get(GetBytesFlashRequest(offset=offset, length=length))
806048
def locate(self, pattern, big_endian=False):
        """"""
        space, self.space = tee(self.space)
        if pattern.startswith('0x'):
            target = unhexlify(
                pattern[2:].encode('utf-8')).decode('utf-8')
            if not big_endian:
                target = target[::-1]
        else:
            target = pattern
        for index, one in enumerate(window(space, self.position)):
            if ''.join(one) == target[:self.position]:
                return index
        raise KeyError('{target} Not Found In {sets}!'.format(
            target=pattern, sets=self.sets))
168690
def get_range(self):
        """"""
        p, z = np.asarray(self.pan), np.asarray(self.zoom)
        x0, y0 = -1. / z - p
        x1, y1 = +1. / z - p
        return (x0, y0, x1, y1)
667488
protected void findAdjacentRegions(GrayS32 pixelToRegion) {
		// -------- Do the inner pixels first
		if( connect.length == 4 )
			adjacentInner4(pixelToRegion);
		else if( connect.length == 8 ) {
			adjacentInner8(pixelToRegion);
		}

		adjacentBorder(pixelToRegion);
	}
927101
def average_over_area(q, x, y):
    """"""
    area = (np.max(x) - np.min(x))*(np.max(y) - np.min(y))
    integral = np.trapz(np.trapz(q, y, axis=0), x)
    return integral/area
452784
def p_bound_segments(self, p):
        """"""
        p[0] = p[1]
        if len(p) > 2:
            p[0].extend(p[3])
918129
public static AreaD area(final AreaSizeD size)
  {
    Objects.requireNonNull(size, "Size");
    return AreaD.of(0.0, size.sizeX(), 0.0, size.sizeY());
  }
174049
def _obtain_region(self, a, offset, size, flags, is_recursive):
        """"""
        if self._memory_size + size > self._max_memory_size:
            self._collect_lru_region(size)
        # END handle collection

        r = None
        if a:
            assert len(a) == 1
            r = a[0]
        else:
            try:
                r = self.MapRegionCls(a.path_or_fd(), 0, sys.maxsize, flags)
            except Exception:
                # apparently we are out of system resources or hit a limit
                # As many more operations are likely to fail in that condition (
                # like reading a file from disk, etc) we free up as much as possible
                # As this invalidates our insert position, we have to recurse here
                if is_recursive:
                    # we already tried this, and still have no success in obtaining
                    # a mapping. This is an exception, so we propagate it
                    raise
                # END handle existing recursion
                self._collect_lru_region(0)
                return self._obtain_region(a, offset, size, flags, True)
            # END handle exceptions

            self._handle_count += 1
            self._memory_size += r.size()
            a.append(r)
        # END handle array

        assert r.includes_ofs(offset)
        return r
263327
def get_sub_area(area, xslice, yslice):
    """"""
    new_area_extent = ((area.pixel_upper_left[0] +
                        (xslice.start - 0.5) * area.pixel_size_x),
                       (area.pixel_upper_left[1] -
                        (yslice.stop - 0.5) * area.pixel_size_y),
                       (area.pixel_upper_left[0] +
                        (xslice.stop - 0.5) * area.pixel_size_x),
                       (area.pixel_upper_left[1] -
                        (yslice.start - 0.5) * area.pixel_size_y))

    return AreaDefinition(area.area_id, area.name,
                          area.proj_id, area.proj_dict,
                          xslice.stop - xslice.start,
                          yslice.stop - yslice.start,
                          new_area_extent)
1326500
public int findRegion(int idx) {

    for (int i = 0; i < populationSize; i++) {
      if (subregionIdx[i][idx] == 1) {
        return i;
      }
    }

    return -1;
  }
913014
def segment_area(seg):
    '''
    '''
    r0 = seg[0][COLS.R]
    r1 = seg[1][COLS.R]
    h2 = point_dist2(seg[0], seg[1])
    return math.pi * (r0 + r1) * math.sqrt((r0 - r1) ** 2 + h2)