Points.replace¶
- Points.replace(data, points=None, *, useLog=None, **dataKwds)¶
Replace the data in one or more of the points in this object.
If
points=None
, the data must be a nimble data object with matching pointNames, matching pointNames must be specified as adataKwds
argument or the data must replace all points. Otherwise, the shape of thedata
object must align with thepoints
parameter. Index values inpoints
will take priority over matching pointNames.- Parameters:
data – The object containing the data to use as a replacement. This can be any
source
accepted bynimble.data
.points (identifier, list, None) – The point (name or index) or list of points to replace with the provided data.
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.
dataKwds – Any keyword arguments accepted by
nimble.data
to use to construct a nimble data object fromdata
. These only apply whendata
is not already a nimble data object.
See also
Examples
>>> obj = nimble.zeros(3, 3, pointNames=['a', 'b', 'c']) >>> newPt = nimble.ones(1, 3, pointNames=['b']) >>> obj.points.replace(newPt, points='b') >>> obj <Matrix 3pt x 3ft 0 1 2 ┌──────── a │ 0 0 0 b │ 1 1 1 c │ 0 0 0 >
>>> obj = nimble.zeros(4, 3, returnType='Sparse') >>> replacement = [[1, 2, 3], [9, 8, 7]] >>> obj.points.replace(replacement, [1, 2]) >>> obj <Sparse 4pt x 3ft 0 1 2 ┌──────── 0 │ 0 0 0 1 │ 1 2 3 2 │ 9 8 7 3 │ 0 0 0 >
>>> obj = nimble.zeros(3, 3, pointNames=['a', 'b', 'c']) >>> obj.points.replace([2, 3, 2], pointNames=['b']) >>> obj <Matrix 3pt x 3ft 0 1 2 ┌──────── a │ 0 0 0 b │ 2 3 2 c │ 0 0 0 >
Keywords: change, substitute, alter, transform