hpcflow.sdk.core.utils.swap_nested_dict_keys#

hpcflow.sdk.core.utils.swap_nested_dict_keys(dct, inner_key)#

Return a copy where top-level keys have been swapped with a second-level inner key.

Examples:#

>>> swap_nested_dict_keys(
    dct={
        'p1': {'format': 'direct', 'all_iterations': True},
        'p2': {'format': 'json'},
        'p3': {'format': 'direct'},
    },
    inner_key="format",
)
{
    "direct": {"p1": {"all_iterations": True}, "p3": {}},
    "json": {"p2": {}},
}
Parameters:
  • dct (dict[~T, dict[~T2, ~T3]]) –

  • inner_key (T2) –