nip.parameters.agents.AgentsParameters#
- class nip.parameters.agents.AgentsParameters[source]#
Parameters which specify the agents in the experiment.
A subclass of
dict
which contains the parameters for each agent in the experiment.The keys are the names of the agents, and the values are the parameters for each agent.
Agent names must not be substrings of each other.
If the special key “_default” is present in the dictionary, its value is used as the default parameters when accessing an agent name not present in the dictionary. This is useful for specifying default parameters for all agents.
Methods Summary
__contains__
(key)Check if the agent name is present in the dictionary.
__getitem__
(key)Get the agent parameters for the given agent name.
Return a string representation of the combined agents update schedule.
_get_param_class_from_dict
(param_dict)Try to get the parameter class from a dictionary of serialised parameters.
from_dict
(params_dict[, ignore_extra_keys])Create a parameters object from a dictionary.
to_dict
()Convert the parameters object to a dictionary.
Methods
- __contains__(key: str) bool [source]#
Check if the agent name is present in the dictionary.
- Parameters:
key (str) – The name of the agent.
- Returns:
contains_key (bool) – Whether the agent name is present in the dictionary.
- __getitem__(key: str) AgentParameters [source]#
Get the agent parameters for the given agent name.
- Parameters:
key (str) – The name of the agent. If the agent name is not present in the dictionary, but the special key “_default” is present, the value of “_default” is returned.
- Returns:
agent_params (AgentParameters) – The parameters for the agent.
- Raises:
KeyError – If the agent name is not present in the dictionary and the special key “_default” is not present.
- _agents_update_repr() str [source]#
Return a string representation of the combined agents update schedule.
- Returns:
agents_update_repr (str) – A string representation of the combined agents update schedule.
- classmethod _get_param_class_from_dict(param_dict: dict) type[ParameterValue] | None [source]#
Try to get the parameter class from a dictionary of serialised parameters.
- Parameters:
param_dict (dict) – A dictionary of parameters, which may have come from a
to_dict
method. This dictionary may contain a_type
key, which is used to determine the class of the parameter.- Returns:
param_class (type[ParameterValue] | None) – The class of the parameter, if it can be determined.
- Raises:
ValueError – If the class specified in the dictionary is not a valid parameter class.
- classmethod from_dict(params_dict: dict, ignore_extra_keys: bool = False) AgentsParameters [source]#
Create a parameters object from a dictionary.