moveaxis_to_start#
- moveaxis_to_start = functools.partial(<function moveaxis>, destination=0)#
numpy.moveaxis()withdestination=0pre-applied.Moves a nominated source axis to position 0 (the leading axis) while keeping all other axes in their original relative order. This is used throughout the polydata builder functions in
pyvisual.core.mesh3dto bring the “stack” axis to the front before reshaping, enabling uniform downstream iteration over batches of curves or surface slices.For example, if a fieldline array has shape
(N_r, N_lines)with the line index on axis 1,moveaxis_to_start(arr, 1)returns a view of shape(N_lines, N_r)without copying data.- Parameters:
- a
np.ndarray Input array.
- source
int|Sequence[int] Original position(s) of the axis (or axes) to move.
- **kwargs
Any additional keyword arguments accepted by
numpy.moveaxis().destinationis already fixed to0and cannot be overridden.
- a
- Returns:
- out
np.ndarray View of
awith the specified axis moved to position 0.
- out
See also
numpy.moveaxis()The underlying NumPy function.
ij_meshgridCompanion partial used to broadcast 1-D coordinate arrays before axis reordering.
Examples
Move the line-index axis of a fieldline coordinate array to the front:
>>> import numpy as np >>> arr = np.zeros((100, 5, 3)) # shape: (N_r, N_lines, xyz) >>> out = moveaxis_to_start(arr, 1) >>> out.shape (5, 100, 3)