Tools

Merge two dictionaries

PEPit.tools.merge_dict(dict1, dict2)[source]

Merge keys of dict1 and dict2. If a key is in the 2 dictionaries, then add the values.

Parameters
  • dict1 (dict) – any dictionary

  • dict2 (dict) – any dictionary

Returns

merged_dict (dict) – the union of the 2 inputs with added values.

Multiply two dictionaries

PEPit.tools.multiply_dicts(dict1, dict2)[source]

Multiply 2 dictionaries in the sense of developing a product of 2 sums.

Parameters
  • dict1 (dict) – any dictionary

  • dict2 (dict) – any dictionary

Returns

product_dict (dict) – the keys are the couple of keys of dict1 and dict2 and the values the product of values of dict1 and dict2.

Prune a dictionary

PEPit.tools.prune_dict(my_dict)[source]

Remove all keys associated to a null value.

Parameters

my_dict (dict) – any dictionary

Returns

pruned_dict (dict) – pruned dictionary