from typing import List
from typing import Dict


def grand_sum_totals(totals: List[Dict[str, float]],
                     ignore=['B', 'N', ]) -> float:
    """Calculate the sum of all compartments.

    Takes the output list generated using calc_totals and calculates the sum of
    all the compartments.

    E.g. print(grand_sum_totals([calc_totals[m] for m in model_list])

    Parameters:
    totals (output of calc_totals): list of compartment totals across models
    ignore (list of str): list of compartments to ignore

    """
    total = 0.0
    for t in totals:
        for key, value in t.items():
            if key not in ignore:
                total += value
    return total