register_combiner

passengersim.callbacks.register_combiner(process: str, combiner: Callable[[DataFrame, DataFrame], DataFrame]) → None[source]

Register how tables declaring an aggregation process are combined.

A tracer declares its process by setting df.attrs["aggregation_process"] on the table returned by its finalize method. Register the combiner in the module that defines the tracer, so that it is available whenever that module is imported, including before loading saved results that use it.

Parameters:
process : str

The process identifier. It is stored with saved results, so it must never change meaning once results using it exist.

combiner : Callable[[pd.DataFrame, pd.DataFrame], pd.DataFrame]

Function combining two tables that both declare process into a new table, without modifying either. The result must also declare process, so that it can be combined again.

Raises:
  • ValueError – If process is empty or already registered.

  • TypeError – If combiner is not callable.