register_circuity_function

passengersim.connection_builder.circuity.register_circuity_function(func: Callable[[dict[str, Airport], tuple[Leg, ...], str | None, int], bool], name: str | None = None) Callable[[dict[str, Airport], tuple[Leg, ...], str | None, int], bool][source]

Register a circuity function.

This can be used to register a user-defined circuity function that can then be used in the connection builder. The name used for registration is the provided name parameter, or the function’s __name__ if name is not provided. The registered circuity function can then be retrieved by name using get_registered_circuity_function(name).

Parameters:
func : CircuityFunc

The circuity function to register.

name : str | None, optional

The name to register the circuity function under. If None, the function’s __name__ attribute will be used. Defaults to None.

Returns:

CircuityFunc – The same circuity function that was registered. This allows this function to be used as a decorator to register a circuity function but otherwise act transparently.

Raises:

ValueError – If a circuity function is already registered under name.