coords.Coords.replicate#

Coords.replicate(n, dir=0, step=1.0)#

Replicate a Coords n times with a fixed translation step.

Parameters#

n: int

Number of copies to create.

dir: int (0,1,2) or float array_like (3,)

The translation vector. If an int, it specifies a global axis and the translation is in the direction of that axis: 0 (X-axis), 1 (Y-axis) and 2 (Z-axis). If an array_like, it specifies a translation vector.

step: float

If dir is an int, this is the length of the translation. Else, it is a multiplying factor applied to the translation vector.

Returns#

Coords

A Coords with an extra first axis with length n. The new shape thus becomes (n,) + self.shape. The first component along the axis 0 is identical to the original Coords. Each following component is equal to the previous translated over (dir,step), where dir and step are interpreted just like in the translate() method.

Examples#

>>> Coords([0.,0.,0.]).replicate(4, dir=1, step=1.2)
Coords([[0. , 0. , 0. ],
        [0. , 1.2, 0. ],
        [0. , 2.4, 0. ],
        [0. , 3.6, 0. ]])
>>> Coords([0.]).replicate(3, dir=0).replicate(2, dir=1)
Coords([[[0., 0., 0.],
         [1., 0., 0.],
         [2., 0., 0.]],

        [[0., 1., 0.],
         [1., 1., 0.],
         [2., 1., 0.]]])
>>> Coords([0.,0.,0.]).replicate(4, dir=[0.0, 1.0, 0.0], step=1.2)
Coords([[0. , 0. , 0. ],
        [0. , 1.2, 0. ],
        [0. , 2.4, 0. ],
        [0. , 3.6, 0. ]])