simplebench.reporters.choices.choices_conf module🔗
ChoicesConf class for reporters.
This module defines the ChoicesConf class, which is a container for managing
ChoiceConf instances used in reporter configurations.
It ensures type safety by enforcing that only
ChoiceConf instances can be added
to the container, and provides methods for adding, retrieving, and managing
these instances.
It is designed to be used in the context of reporters that require
a collection of ChoiceConf instances.
It has no methods of its own; all functionality is inherited from
_BaseChoices.
- class simplebench.reporters.choices.choices_conf.ChoicesConf(
- choices: Iterable[ChoiceConf] | ChoicesConf | None = None,
Bases:
_BaseChoices[ChoiceConf,_ChoicesErrorTag]A dictionary-like container for
ChoiceConfinstances.This class enforces that only
ChoiceConfinstances 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
ChoiceConfinstances.Construct a
Choicescontainer.- Parameters:
choices (Iterable[
ChoiceConf] |ChoicesConf| None) – AnIterableofChoiceConfinstances or anotherChoicesConfinstance to initialize the container with. IfNone, an empty container is created.
- add(
- choice: ChoiceConf,
Add a
ChoiceConfinstance to the container.The
choice.nameattribute is used as the key in the container and is required to be unique withing the container.- Parameters:
choice (
ChoiceConf) – TheChoiceConfinstance to add.- Raises:
SimpleBenchTypeError – If the argument is not a
ChoiceConfinstance.SimpleBenchValueError – If a
ChoiceConfwith the same name already exists in the container.
- extend(
- choices: Iterable[ChoiceConf] | ChoicesConf,
Add
ChoiceConfinstances to the container.It does so by adding each
ChoiceConfin the providedIterableofChoiceConfor by adding theChoiceConfinstances from the providedChoicesConfinstance.- Parameters:
choices (Iterable[
ChoiceConf] |ChoicesConf) – AnIterableofChoiceConfinstances or an instance ofChoicesConf.- Raises:
SimpleBenchTypeError – If the
choicesargument is not anIterableofChoiceConfinstances or aChoicesConfinstance.SimpleBenchValueError – If any
ChoiceConfin theIterablehas a duplicate name that already exists in the container.
- remove(name: str) None[source]🔗
Remove a
ChoiceConfinstance from the container by its name.- Parameters:
name (str) – The name of the
ChoiceConfinstance to remove.- Raises:
SimpleBenchKeyError – If no
ChoiceConfunder the given name exists in the container.