Features.insert

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

Insert more features into this object.

Expand this object by inserting the features of toInsert prior to the insertBefore identifier. The points 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 point order if there is an unambiguous mapping. toInsert will be unaffected by calling this method.

Parameters:
  • insertBefore (identifier) – The index or feature 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 point names as the calling object, but not necessarily in the same order. Must not share any feature 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(3, 2)
>>> toInsert = nimble.ones(3, 2)
>>> X.features.insert(1, toInsert)
>>> X
<Matrix 3pt x 4ft
     0  1  2  3
   ┌───────────
 0 │ 0  1  1  0
 1 │ 0  1  1  0
 2 │ 0  1  1  0
>

Insert before another point; mixed object types.

>>> lstData = [[1, 4], [5, 8]]
>>> X = nimble.data(lstData, featureNames=['1', '4'])
>>> lstInsert = [[2, 3], [6, 7]]
>>> toInsert = nimble.data(lstInsert,
...                        featureNames=['2', '3'])
>>> X.features.insert('4', toInsert)
>>> X
<Matrix 2pt x 4ft
     1  2  3  4
   ┌───────────
 0 │ 1  2  3  4
 1 │ 5  6  7  8
>

Reorder names.

>>> lstData = [[1, 2], [5, 6]]
>>> X = nimble.data(lstData, pointNames=['a', 'b'])
>>> lstInsert = [[7, 8], [3, 4]]
>>> toInsert = nimble.data(lstInsert,
...                        pointNames=['b', 'a'])
>>> X.features.insert(2, toInsert)
>>> X
<Matrix 2pt x 4ft
     0  1  2  3
   ┌───────────
 a │ 1  2  3  4
 b │ 5  6  7  8
>

Keywords: embed, include, inject, alter, position