def label_set_permutate(self) -> List[Tuple[str, ...]]: """ Returns a list of label sets, where each label set is a tuple of strings """ check.list_t(self.label_set, str) return utils.flatten([ self._label_str_permutate(label_str) for label_str in self.label_set ], 1)
def it_flattens_two_levels(): f = flatten([[1, 2, [3, 4, [5, 6]]], [7]], depth=2) assert f == [1, 2, 3, 4, [5, 6], 7]
def it_flattens_one_level(): f = flatten([[1, 2, [3, 4, [5, 6]]], [7]], depth=1) assert f == [1, 2, [3, 4, [5, 6]], 7]
def it_flattens_a_tuples(): assert flatten([[1, 2], [3, 4, (5, 6)]]) == [1, 2, 3, 4, 5, 6]
def it_flattens_all_levels(): f = flatten([[1, 2, [3, 4, [5, 6]]]]) assert f == [1, 2, 3, 4, 5, 6]
def it_flattens_a_multilevel_list(): assert flatten([[1, 2], [3, 4, [5, "abc"]]]) == [1, 2, 3, 4, 5, "abc"]
def label_set_permutate(self): check.list_t(self.label_set, str) return utils.flatten([ self._label_str_permutate(label_str) for label_str in self.label_set ], 1)