hpcflow.sdk.core.utils.dict_values_process_flat#

hpcflow.sdk.core.utils.dict_values_process_flat(d, callable)#

Return a copy of a dict, where the values are processed by a callable that is to be called only once, and where the values may be single items or lists of items.

Examples

d = {‘a’: 0, ‘b’: [1, 2], ‘c’: 5} >>> dict_values_process_flat(d, callable=lambda x: [i + 1 for i in x]) {‘a’: 1, ‘b’: [2, 3], ‘c’: 6}

Parameters:
  • d (Mapping[T, T2 | list[T2]]) –

  • callable (Callable[[list[T2]], list[T3]]) –

Return type:

Mapping[T, T3 | list[T3]]