gen_combs#

mbgdml.utils.gen_combs(sets, replacement=False)[source]#

Generate combinations from multiple sets.

Parameters:
  • sets (list or tuple, ndim: 2) – An iterable that contains multiple sets.

  • replacement (bool, default: False) – Allows repeated combinations in different order. If False, (0, 1) and (1, 0) could be possible if there is overlap in the sets.

Yields:

tuple – Combination of one element per set in sets.

Examples

>>> sets = ((0,) (1, 2), (1, 2, 3))
>>> combs = gen_combs(sets)
>>> for comb in combs:
...     print(comb)
...
(0, 1, 2)
(0, 1, 3)
(0, 2, 3)