larray.Session.transpose

Session.transpose(*args) Session[source]

Reorder axes of arrays in session, ignoring missing axes for each array.

Parameters
*args

Accepts either a tuple of axes specs or axes specs as *args. Omitted axes keep their order. Use … to avoid specifying intermediate axes. Axes missing in an array are ignored.

Returns
Session

Session with each array with reordered axes where appropriate.

See also

Array.transpose

Examples

Let us create a test session and a small helper function to display sessions as a short summary.

>>> arr1 = ndtest((2, 2, 2))
>>> arr2 = ndtest((2, 2))
>>> sess = Session({'arr1': arr1, 'arr2': arr2})
>>> def print_summary(s):
...     print(s.summary({Array: "{key} -> {axes_names}"}))
>>> print_summary(sess)
arr1 -> a, b, c
arr2 -> a, b

Put ‘b’ axis in front of all arrays

>>> print_summary(sess.transpose('b'))
arr1 -> b, a, c
arr2 -> b, a

Axes missing on an array are ignored (‘c’ for arr2 in this case)

>>> print_summary(sess.transpose('c', 'b'))
arr1 -> c, b, a
arr2 -> b, a

Use … to move axes to the end

>>> print_summary(sess.transpose(..., 'a'))   
arr1 -> b, c, a
arr2 -> b, a