coords.Coords.swap_axes#

Coords.swap_axes(i, j)#

Swap two coordinate axes.

Parameters#

i: int (0,1,2)

First coordinate axis

j: int (0,1,2)

Second coordinate axis

Returns#

Coords

A Coords with interchanged i and j coordinates.

Warning#

Coords.swap_axes merely changes the order of the elements along the last axis of the ndarray. This is quite different from numpy.ndarray.swapaxes(), which is inherited by the Coords class. The latter method interchanges the array axes of the ndarray, and will not yield a valid Coords object if the interchange involves the last axis.

Notes#

This is equivalent with self.copy_axes((i,j),(j,i))

Swapping two coordinate axes has the same effect as mirroring against the bisector plane between the two axes.

Examples#

>>> X = Coords(np.arange(6).reshape(-1,3))
>>> X
Coords([[0., 1., 2.],
        [3., 4., 5.]])
>>> X.swap_axes(2,0)
Coords([[2., 1., 0.],
        [5., 4., 3.]])
>>> X.swapaxes(1,0)
array([[0., 3.],
       [1., 4.],
       [2., 5.]]...)