coordax.coords.replace_axes¶
- coordax.coords.replace_axes(coordinate: Coordinate, to_replace: Coordinate, replace_with: Coordinate) Coordinate[source]¶
Returns
coordinatewithto_replacereplaced byreplace_with.- Parameters:
coordinate – The coordinate system to modify.
to_replace – A contiguous part of the coordinate system to be replaced.
replace_with – The new coordinate to insert.
- Returns:
A new coordinate object with
to_replacesubstituted byreplace_with.- Raises:
ValueError – If
to_replaceis not a contiguous part ofcoordinate.
Examples
>>> import coordax as cx >>> x = cx.SizedAxis('x', 2) >>> y = cx.SizedAxis('y', 3) >>> xy = cx.coords.compose(x, y) >>> xy CartesianProduct(coordinates=(coordax.SizedAxis('x', size=2), coordax.SizedAxis('y', size=3))) >>> z = cx.SizedAxis('z', 4) >>> cx.coords.replace_axes(xy, x, z) CartesianProduct(coordinates=(coordax.SizedAxis('z', size=4), coordax.SizedAxis('y', size=3)))