:py:mod:`collection.toggleable_bool` ==================================== .. py:module:: collection.toggleable_bool .. autoapi-nested-parse:: Add set of conditional booleans that can be used to explore many combinations. ToggleableBoolean are meant to be grouped and their value can be toggled to explore all possible combinations. This can be useful when there is an expression depending on external values that you want to evaluate without knowing in advance the external environment. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: collection.toggleable_bool.ToggleableBooleanGroup collection.toggleable_bool.ToggleableBoolean .. py:class:: ToggleableBooleanGroup Contain group of toggleable boolean. Add a new boolean by calling .add(, ). Then generate all possible combinations by running .shuffle():: group = ToggleableBooleanGroup() group.add('first', True) group.add('second', False) for series in group.shuffle(): print([str(b) for b in series]) Will display:: ['first: True', 'second: True'] ['first: False', 'second: True'] ['first: False', 'second: False'] .. py:method:: __getitem__(key: int) -> ToggleableBoolean Get a toggleable boolean by index. :param key: index of the toggleable boolean .. py:method:: __len__() -> int Return the number of elements in the series. .. py:method:: shuffle() -> collections.abc.Iterator[list[ToggleableBoolean]] Generate all other possible set of values for all conditional booleans. :return: yield a new list of ToggleableBoolean with a different set of value. Calling this function until StopIteration is raised will generate all possible values except the initial set of value. .. py:method:: add(name: str, value: bool) -> ToggleableBoolean Create a new boolean value and add it to this group. :param name: boolean name for debug info :param value: boolean value .. py:class:: ToggleableBoolean(name: str, value: bool) Contain a boolean value that can be toggle in group. See ToggleableBooleanGroup. .. py:method:: __bool__() -> bool Return boolean value of toggleable boolean. .. py:method:: __str__() -> str Return string representation of toggleable boolean.