Points.permute

Points.permute(order=None, *, useLog=None)

Permute the indexing of the points.

Change the arrangement of points in the object. A specific permutation can be provided as the order argument. If order is None, the permutation will be random. Note: a random permutation may be the same as the current permutation.

Parameters:
  • order (list, None) – A list of identifiers indicating the new permutation order. If None, the permutation will be random.

  • 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.

Notes

Random permutation relies on python’s random.shuffle() which may not be sufficiently random for large number of points. See random.shuffle()’s documentation.

See also

sort

Examples

>>> nimble.random.setSeed(42)
>>> lst = [[1, 1, 1, 1],
...        [2, 2, 2, 2],
...        [3, 3, 3, 3],
...        [4, 4, 4, 4]]
>>> X = nimble.data(lst)
>>> X.points.permute()
>>> X
<Matrix 4pt x 4ft
     0  1  2  3
   ┌───────────
 0 │ 3  3  3  3
 1 │ 2  2  2  2
 2 │ 4  4  4  4
 3 │ 1  1  1  1
>

Permute with a list of identifiers.

>>> lst = [['home', 81, 3],
...        ['gard', 98, 10],
...        ['home', 14, 1],
...        ['home', 11, 3]]
>>> pts = ['o_4', 'o_3', 'o_2', 'o_1']
>>> orders = nimble.data(lst, pointNames=pts)
>>> orders.points.permute(['o_1', 'o_2', 'o_3', 'o_4'])
>>> orders
<DataFrame 4pt x 3ft
        0    1   2
     ┌─────────────
 o_1 │ home  11   3
 o_2 │ home  14   1
 o_3 │ gard  98  10
 o_4 │ home  81   3
>

Keywords: reorder, rearrange, shuffle