Source code for ananke.utils
from itertools import chain, combinations
[docs]def powerset(iterable, min_size=0):
"powerset([1,2,3], 0) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)"
s = list(iterable)
return chain.from_iterable(
(combinations(s, r)) for r in range(min_size, len(s) + 1)
)