forked from p34709852/monkey
made power set return lists for ease of usage
This commit is contained in:
parent
e500068e45
commit
547067c4da
|
@ -6,4 +6,4 @@ def power_set(iterable):
|
|||
https://docs.python.org/3/library/itertools.html#itertools-recipes
|
||||
"""
|
||||
s = list(iterable)
|
||||
return chain.from_iterable(combinations(s, r) for r in range(1, len(s) + 1))
|
||||
return [list(x) for x in list(chain.from_iterable(combinations(s, r) for r in range(1, len(s) + 1)))]
|
|
@ -5,14 +5,14 @@ class TestPower_set(TestCase):
|
|||
def test_power_set(self):
|
||||
before = ('a', 'b', 'c')
|
||||
after_expected = [
|
||||
('a', ),
|
||||
('b',),
|
||||
('c',),
|
||||
('a', 'b'),
|
||||
('a', 'c'),
|
||||
('b', 'c'),
|
||||
('a', 'b', 'c'),
|
||||
['a'],
|
||||
['b'],
|
||||
['c'],
|
||||
['a', 'b'],
|
||||
['a', 'c'],
|
||||
['b', 'c'],
|
||||
['a', 'b', 'c'],
|
||||
]
|
||||
|
||||
from common.utils.itertools_extensions import power_set
|
||||
self.assertEquals(list(power_set(before)), after_expected)
|
||||
self.assertEquals(power_set(before), after_expected)
|
||||
|
|
Loading…
Reference in New Issue