def process(*cubes: cli.inputcube,
            coordinates: cli.comma_separated_list = None):
    """Aggregate reliability tables.

    Aggregate multiple reliability calibration tables and/or aggregate over
    coordinates within the table(s) to produce a new reliability calibration
    table.

    Args:
        cubes (list of iris.cube.Cube):
            The cube or cubes containing the reliability calibration tables
            to aggregate.
        coordinates (list):
            A list of coordinates over which to aggregate the reliability
            calibration table using summation. If the list is empty
            and a single cube is provided, this cube will be returned
            unchanged.
    Returns:
        iris.cube.Cube:
            Aggregated reliability table.
    """
    from improver.calibration.reliability_calibration import (
        AggregateReliabilityCalibrationTables, )

    return AggregateReliabilityCalibrationTables()(cubes,
                                                   coordinates=coordinates)
def test_process_and_aggregate(create_rel_table_inputs):
    """Test that aggregation during construction produces the same result as
    applying the two plugins sequentially."""
    # use the spatial coordinates for aggregation - input is a parameterised fixture
    if create_rel_table_inputs.forecast.coords("spot_index"):
        agg_coords = ["spot_index"]
    else:
        agg_coords = ["longitude", "latitude"]

    # construct and aggregate as two separate plugins
    constructed = Plugin(
        single_value_lower_limit=True, single_value_upper_limit=True
    ).process(create_rel_table_inputs.forecast, create_rel_table_inputs.truth)
    aggregated = AggregateReliabilityCalibrationTables().process(
        [constructed], agg_coords
    )

    # construct plugin with aggregate_coords option
    constructed_with_agg = Plugin(
        single_value_lower_limit=True, single_value_upper_limit=True
    ).process(
        create_rel_table_inputs.forecast, create_rel_table_inputs.truth, agg_coords
    )

    # check that the two cubes are identical
    assert constructed_with_agg == aggregated