simplebench.reporters.choices package🔗

simplebench.reporters.choices package.

class simplebench.reporters.choices.Choices(
choices: Iterable[Choice] | Choices | None = None,
)[source]🔗

Bases: _BaseChoices[Choice, _ChoicesErrorTag]

A dictionary-like container for Choice instances.

This class enforces that only Choice instances 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 Choice instances.

Construct a Choices container.

Parameters:

choices (Iterable[Choice] | Choices | None) – An Iterable of Choice instances or another Choices instance to initialize the container with. If None, an empty container is created.

add(choice: Choice) None[source]🔗

Add a Choice instance to the container.

The choice.name attribute is used as the key in the container and is required to be unique withing the container.

Parameters:

choice (Choice) – The Choice instance to add.

Raises:
all_choice_args() set[str][source]🔗

Return a set of all Namespace arg names from all Choice instances in the container.

Returns:

A set of all Namespace arg names from all Choice instances.

Return type:

set[str]

all_choice_flags() set[str][source]🔗

Return a set of all CLI flags from all Choice instances in the container.

Returns:

A set of all CLI flags from all Choice instances.

Return type:

set[str]

extend(
choices: Iterable[Choice] | Choices,
) None[source]🔗

Add Choice instances to the container. It does so by adding each Choice in the provided Iterable of Choice or by adding the Choice instances from the provided Choices instance.

Parameters:

choices (Iterable[Choice] | Choices) – An Iterable of Choice instances or an instance of Choices.

Raises:
get_choice_for_arg(
arg: str,
) Choice | None[source]🔗

Return the Choice instance associated with the given Namespace arg name.

Parameters:

arg (str) – The Namespace arg name to look up.

Returns:

The Choice instance associated with the arg, or None if no such Choice exists.

Return type:

Choice | None

Raises:

SimpleBenchTypeError – If the arg is not a string.

remove(name: str) None[source]🔗

Remove a Choice instance from the container by its name.

Parameters:

name (str) – The name of the Choice instance to remove.

Raises:

SimpleBenchKeyError – If no Choice under the given name exists in the container.

class simplebench.reporters.choices.ChoicesConf(
choices: Iterable[ChoiceConf] | ChoicesConf | None = None,
)[source]🔗

Bases: _BaseChoices[ChoiceConf, _ChoicesErrorTag]

A dictionary-like container for ChoiceConf instances.

This class enforces that only ChoiceConf instances 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 ChoiceConf instances.

Construct a Choices container.

Parameters:

choices (Iterable[ChoiceConf] | ChoicesConf | None) – An Iterable of ChoiceConf instances or another ChoicesConf instance to initialize the container with. If None, an empty container is created.

add(
choice: ChoiceConf,
) None[source]🔗

Add a ChoiceConf instance to the container.

The choice.name attribute is used as the key in the container and is required to be unique withing the container.

Parameters:

choice (ChoiceConf) – The ChoiceConf instance to add.

Raises:
extend(
choices: Iterable[ChoiceConf] | ChoicesConf,
) None[source]🔗

Add ChoiceConf instances to the container.

It does so by adding each ChoiceConf in the provided Iterable of ChoiceConf or by adding the ChoiceConf instances from the provided ChoicesConf instance.

Parameters:

choices (Iterable[ChoiceConf] | ChoicesConf) – An Iterable of ChoiceConf instances or an instance of ChoicesConf.

Raises:
remove(name: str) None[source]🔗

Remove a ChoiceConf instance from the container by its name.

Parameters:

name (str) – The name of the ChoiceConf instance to remove.

Raises:

SimpleBenchKeyError – If no ChoiceConf under the given name exists in the container.

Submodules🔗