sweetpea.internal module¶
This module provides some convenience functions to be used internally.
- sweetpea.internal.get_all_external_level_names(design)¶
Usage
>>> color = Factor("color", ["red", "blue"]) >>> text = Factor("text", ["red", "blue"]) >>> get_all_internal_level_names([color, text]) [('color', 'red'), ('color', 'blue'), ('text', 'red'), ('text', 'blue')]
- Parameters
design (List[sweetpea.primitives.Factor]) –
- Return type
- sweetpea.internal.get_all_internal_level_names(design)¶
- Parameters
design (List[sweetpea.primitives.Factor]) –
- Return type
- sweetpea.internal.get_all_levels(design)¶
- Parameters
design (List[sweetpea.primitives.Factor]) –
- Return type
List[Tuple[sweetpea.primitives.Factor, Union[sweetpea.primitives.SimpleLevel, sweetpea.primitives.DerivedLevel]]]
- sweetpea.internal.chunk(it, size)¶
Handy-dandy chunker from SO: https://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks
- Parameters
it (Iterable[Any]) –
size (int) –
- Return type
Iterator[Tuple[Any, …]]
- sweetpea.internal.chunk_list(it, size)¶
- Parameters
it (Iterable[Any]) –
size (int) –
- Return type
Iterator[List[Any]]
- sweetpea.internal.pairwise(iterable)¶
Helper recipe from: https://docs.python.org/3/library/itertools.html#itertools-recipes
s -> (s0,s1), (s1,s2), (s2, s3), ...
- sweetpea.internal.intersperse(delimiter, seq, repeat_delimiter=1)¶
Another helper from SO, with modification for repeating the delimiter. https://stackoverflow.com/questions/5655708/python-most-elegant-way-to-intersperse-a-list-with-an-element