simplebench.reporters.choices.choices module🔗
Choices for reporters.
- class simplebench.reporters.choices.choices.Choices( )[source]🔗
Bases:
_BaseChoices[Choice,_ChoicesErrorTag]A dictionary-like container for
Choiceinstances.This class enforces that only
Choiceinstances can be added to it, and provides methods to manage and retrieve those instances.It is designed to be used in the context of reporters that require a collection of
Choiceinstances.Construct a
Choicescontainer.- Parameters:
choices (Iterable[
Choice] |Choices| None) – AnIterableofChoiceinstances or anotherChoicesinstance to initialize the container with. IfNone, an empty container is created.
- add(choice: Choice) None[source]🔗
Add a
Choiceinstance to the container.The
choice.nameattribute is used as the key in the container and is required to be unique withing the container.- Parameters:
- Raises:
SimpleBenchTypeError – If the argument is not a
Choiceinstance.SimpleBenchValueError – If a
Choicewith the same name already exists in the container.
- all_choice_args() set[str][source]🔗
Return a set of all
Namespacearg names from allChoiceinstances in the container.
- all_choice_flags() set[str][source]🔗
Return a set of all CLI flags from all
Choiceinstances in the container.
- extend( ) None[source]🔗
Add
Choiceinstances to the container. It does so by adding eachChoicein the providedIterableofChoiceor by adding theChoiceinstances from the providedChoicesinstance.- Parameters:
choices (Iterable[
Choice] |Choices) – AnIterableofChoiceinstances or an instance ofChoices.- Raises:
SimpleBenchTypeError – If the
choicesargument is not anIterableofChoiceinstances or aChoicesinstance.SimpleBenchValueError – If any
Choicein theIterablehas a duplicate name that already exists in the container.
- get_choice_for_arg(
- arg: str,
Return the
Choiceinstance associated with the givenNamespacearg name.- Parameters:
arg (str) – The
Namespacearg name to look up.- Returns:
The
Choiceinstance associated with the arg, orNoneif no suchChoiceexists.- Return type:
Choice| None- Raises:
SimpleBenchTypeError – If the arg is not a string.