coordax.coords.replace_axes

coordax.coords.replace_axes(coordinate: Coordinate, to_replace: Coordinate, replace_with: Coordinate) Coordinate[source]

Returns coordinate with to_replace replaced by replace_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_replace substituted by replace_with.

Raises:

ValueError – If to_replace is not a contiguous part of coordinate.

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)))