qspec logo qspec logo

A physics toolbox for laser spectroscopy.

Static Badge Static Badge Static Badge

Static Badge Static Badge

© 2026 Patrick Müller. All rights reserved.

qspec. combine_dicts  (  dicts ,  key_lists ,  operator='+' ,  short_keys=True  )[source]

Combine the values of several dictionaries with the given operator, e.g., for operator == "+", the dictionary {key_lists[0][i] + key_lists[1][i] + ...: dicts[0][key_lists[0][i]] + dicts[1][key_lists[1][i]] + ...}.

Parameters:
dictslist

A list of dictionaries to be combined.

key_listsIterable

A list of iterables of the same length which include keys from the corresponding dicts. Must have the same length as dicts.

operatorstr

The operator which is used to combine the values. Can be one of "+", "-", "*", "/", "%" or "gauss" (the square root of the sum of squares).

short_keysbool

Whether to use the keys of the first key list or representations of the entire operations as the new keys.

Returns:
a_combdict

The dictionary with the combined values.

Raises:
ValueError

If operator is not supported.