def _check_keys(a, b: Resources): if not set(a.keys()) == set(b.keys()): raise ValueError( 'the same dimensions must be provided for both resources %r vs %r', a.keys(), b.keys())
def sum_resources(a: Resources, b: Resources) -> Resources: _check_keys(a, b) c = {} for resource in a.keys(): c[resource] = a[resource] + b[resource] return c