Points.insert

Points.insert(insertBefore, toInsert, *, useLog=None)

Insert more points into this object.

Expand this object by inserting the points of toInsert prior to the insertBefore identifier. The features in toInsert do not need to be in the same order as in the calling object; the data will automatically be placed using the calling object’s feature order if there is an unambiguous mapping. toInsert will be unaffected by calling this method.

Parameters:
  • insertBefore (identifier) – The index or point name prior to which the data from toInsert will be inserted.

  • toInsert (nimble Base object) – The nimble Base object whose contents we will be including in this object. Must have the same number of features as the calling object, but not necessarily in the same order. Must not share any point names with the calling object.

  • 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

append

Examples

Insert data; default names.

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

Insert before another point; mixed object types.

>>> lstData = [[1, 1, 1], [4, 4, 4]]
>>> X = nimble.data(lstData, pointNames=['1', '4'])
>>> lstInsert = [[2, 2, 2], [3, 3, 3]]
>>> toInsert = nimble.data(lstInsert, pointNames=['2', '3'])
>>> X.points.insert('4', toInsert)
>>> X
<Matrix 4pt x 3ft
     0  1  2
   ┌────────
 1 │ 1  1  1
 2 │ 2  2  2
 3 │ 3  3  3
 4 │ 4  4  4
>

Reorder names.

>>> lstData = [[1, 2, 3], [1, 2, 3]]
>>> X = nimble.data(lstData, featureNames=['a', 'b', 'c'])
>>> lstInsert = [[3, 2, 1], [3, 2, 1]]
>>> toInsert = nimble.data(lstInsert,
...                        featureNames=['c', 'b', 'a'])
>>> X.points.insert(0, toInsert)
>>> X
<Matrix 4pt x 3ft
     a  b  c
   ┌────────
 0 │ 1  2  3
 1 │ 1  2  3
 2 │ 1  2  3
 3 │ 1  2  3
>