Replace rectangle with its finite version.
437110
def normalize(self):
        """"""
        if self.x1 < self.x0:
            self.x0, self.x1 = self.x1, self.x0
        if self.y1 < self.y0:
            self.y0, self.y1 = self.y1, self.y0
        return self
481828
def add_waste(self, x, y, width, height):
        """"""
        self._add_section(Rectangle(x, y, width, height))
1121831
def replace(self, v):
        """"""
        if self.popsize < self._popsize:
            return self.add(v)
        k = self.tournament(negative=True)
        self.clean(self.population[k])
        self.population[k] = v
        v.position = len(self._hist)
        self._hist.append(v)
        self.bsf = v
        self.estopping = v
        self._inds_replace += 1
        self._density += self.get_density(v)
        if self._inds_replace == self._popsize:
            self._inds_replace = 0
            self.generation += 1
            gc.collect()
381322
public Rectangle toRelative(Rectangle rect) {
		return new Rectangle(rect.getLeft() - origX, rect.getBottom() - origY, rect.getRight() - origX, rect.getTop()
				- origY);
	}
1126361
public void invalidateRegion (int x, int y, int width, int height)
    {
        if (isValidSize(width, height)) {
            addDirtyRegion(new Rectangle(x, y, width, height));
        }
    }
234516
def replaceRDiagonal(d, arr)
      d = d.to_i
      (0...arr.length).each do |i|
        xy = rDiagonalXY(d, i)
        self[xy['x'], xy['y']] = arr[i]
      end
    end
284120
public void set(Rectangle rectangle) {
        set(rectangle.getX(), rectangle.getY(), rectangle.getWidth(), rectangle.getHeight());
    }
984023
def rect(self, x, y, width, height, color):
        
        self.context.set_source_rgb(*color)
        self.context.rectangle(self.tx(x), self.ty(y), self.tx(width), self.ty(height))
        self.context.fill()
702445
def transform(self, m):
        """"""
        if len(m) != 6:
            raise ValueError("bad sequ. length")
        self.x, self.y = TOOLS._transform_point(self, m)
        return self
989464
def union_rectangles(R):
    
    if R == []:
        return 0
    X = []
    Y = []
    for j in range(len(R)):
        (x1, y1, x2, y2) = R[j]
        assert x1 <= x2 and y1 <= y2
        X.append(x1)
        X.append(x2)
        Y.append((y1, +1, j))    # generate events
        Y.append((y2, -1, j))
    X.sort()
    Y.sort()
    X2i = {X[i]: i for i in range(len(X))}
    L = [X[i + 1] - X[i] for i in range(len(X) - 1)]
    C = Cover_query(L)
    area = 0
    last = 0
    for (y, delta, j) in Y:
        area += (y - last) * C.cover()
        last = y
        (x1, y1, x2, y2) = R[j]
        i = X2i[x1]
        k = X2i[x2]
        C.change(i, k, delta)
    return area
181309
function replaceAt(items, item, index) {
  var copy = items.slice();
  copy.splice(index, 1, item);
  return copy;
}
1192986
public static void roundInside( RectangleLength2D_F64 bound ) {
		double x0 = Math.ceil(bound.x0);
		double y0 = Math.ceil(bound.y0);
		double x1 = Math.floor(bound.x0+bound.width);
		double y1 = Math.floor(bound.y0+bound.height);

		bound.x0 = x0;
		bound.y0 = y0;
		bound.width = x1-x0;
		bound.height = y1-y0;
	}
56902
protected void mergeVerticalBlocks() {
        for(int i = 0; i < rectangles.size() - 1; i++) {
            for(int j = i + 1; j < rectangles.size(); j++) {
                Rectangle2D.Double firstRect = rectangles.get(i);
                Rectangle2D.Double secondRect = rectangles.get(j);
                if (roughlyEqual(firstRect.x, secondRect.x) && roughlyEqual(firstRect.width, secondRect.width)) {
                    if (roughlyEqual(firstRect.y + firstRect.height, secondRect.y)) {
                        firstRect.height += secondRect.height;
                        rectangles.set(i, firstRect);
                        rectangles.remove(j);
                    }
                }
            }
        }
    }
727954
def rectangle(upper_left_x, upper_left_y, lower_right_x, lower_right_y)
      primitive 'rectangle ' + format('%g,%g %g,%g',
                                      upper_left_x, upper_left_y, lower_right_x, lower_right_y)
    end
592005
def _ilshift(self, n):
        """"""
        assert 0 < n <= self.len
        self._append(Bits(n))
        self._truncatestart(n)
        return self
344116
def _single_replace(self, to_replace, method, inplace, limit):
    
    if self.ndim != 1:
        raise TypeError('cannot replace {0} with method {1} on a {2}'
                        .format(to_replace, method, type(self).__name__))

    orig_dtype = self.dtype
    result = self if inplace else self.copy()
    fill_f = missing.get_fill_func(method)

    mask = missing.mask_missing(result.values, to_replace)
    values = fill_f(result.values, limit=limit, mask=mask)

    if values.dtype == orig_dtype and inplace:
        return

    result = pd.Series(values, index=self.index,
                       dtype=self.dtype).__finalize__(self)

    if inplace:
        self._update_inplace(result._data)
        return

    return result
320486
def rectangle(self, clear_screen=True, x1=10, y1=10, x2=80, y2=40, fill_color='black', outline_color='black'):
        

        if clear_screen:
            self.clear()

        return self.draw.rectangle((x1, y1, x2, y2), fill=fill_color, outline=outline_color)