aac_datasets.utils.collections module

intersect_lists(
lst_of_lst: Sequence[Iterable[T]],
) List[T][source]

Performs intersection of elements in lists (like set intersection), but keep their original order.

list_dict_to_dict_list(
lst: Sequence[Mapping[str, T]],
key_mode: str = 'intersect',
default: Any | None = None,
) Dict[str, List[T]][source]

Convert list of dicts to dict of lists.

Parameters:
  • lst – The list of dict to merge.

  • key_mode – Can be “same” or “intersect”. If “same”, all the dictionaries must contains the same keys otherwise a ValueError will be raised. If “intersect”, only the intersection of all keys will be used in output. If “union”, the output dict will contains the union of all keys, and the missing value will use the argument default.

Returns:

The dictionary of lists.

union_lists(
lst_of_lst: Iterable[Iterable[T]],
) List[T][source]

Performs union of elements in lists (like set union), but keep their original order.