Base.replaceRectangle

Base.replaceRectangle(replaceWith, pointStart, featureStart, pointEnd=None, featureEnd=None, *, useLog=None)

Replace values in the data with other values.

Revise the contents of the calling object so that it contains the provided values in the given location. When replaceWith is a Nimble object, the rectangle shape is defined so only the pointStart and featureStart are required to indicate where the top-left corner of the new data is placed within this object. When replaceWith is a constant, pointEnd and featureEnd must also be set to define the bottom-right corner location of the replacement rectangle within this object.

Parameters:
  • replaceWith (constant or nimble Base object) –

    • constant - a constant numeric value with which to fill the data selection.

    • nimble Base object - Size must be consistent with the given start and end indices.

  • pointStart (int or str) – The inclusive index or name of the first point in the calling object whose contents will be modified.

  • featureStart (int or str) – The inclusive index or name of the first feature in the calling object whose contents will be modified.

  • pointEnd (int, str, None) – The inclusive index or name of the last point in the calling object whose contents will be modified. Required when replaceWith is a constant.

  • featureEnd (int, str, None) – The inclusive index or name of the last feature in the calling object whose contents will be modified. Required when replaceWith is a constant.

  • useLog (bool, None) – Local control for whether to send object creation to the logger. If None (default), use the value as specified in the “logger” “enabledByDefault” configuration option. If True, send to the logger regardless of the global option. If False, do NOT send to the logger, regardless of the global option.

See also

Points.fill, Features.fill

Examples

An object of ones filled with zeros from (0, 0) to (2, 2).

>>> X = nimble.ones(4, 4)
>>> filler = nimble.zeros(2, 2)
>>> X.replaceRectangle(filler, 0, 0, 1, 1)
>>> X
<Matrix 4pt x 4ft
     0  1  2  3
   ┌───────────
 0 │ 0  0  1  1
 1 │ 0  0  1  1
 2 │ 1  1  1  1
 3 │ 1  1  1  1
>

Keywords: revise, insert, square, alter, stamp, cut out