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.



Classes
-------

.. autoapisummary::

   collection.toggleable_bool.ToggleableBooleanGroup
   collection.toggleable_bool.ToggleableBoolean


Module Contents
---------------

.. py:class:: ToggleableBooleanGroup

   Contain group of toggleable boolean.

   Add a new boolean by calling .add(<name>, <bool value>). 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:attribute:: series
      :type:  list[ToggleableBoolean]
      :value: []



   .. py:method:: __getitem__(key: int) -> ToggleableBoolean


   .. py:method:: __len__() -> int


   .. 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:attribute:: value


   .. py:attribute:: name


   .. py:method:: __bool__() -> bool


   .. py:method:: __str__() -> str


