def list_to_set_reducer(self, groups):
"""Flatten nested lists to a set of items
Expected shape of input, List of group results, each item in
group results is list of items to reduce.
[[[item1, item2], [item2, item3]], [[item4, item5]]]
:param groups: List of group results. Each group result is expected to be
an itterable containing itterables of set members.
:returns: List of unique values from the input
:rtype: list
"""
# TODO does this assume too much knowledge of the shape of the input?
# print 'list_to_set_reducer: {}'.format(groups)
s = set()
for g in groups:
for i in g:
s.update(i)
return list(s)
评论列表
文章目录