yawning_titan.config.groups.core.ActionLikelihoodChanceGroup#

class yawning_titan.config.groups.core.ActionLikelihoodChanceGroup(doc=None, use=False, likelihood=None, chance=None)[source]#

Bases: ActionLikelihoodGroup

Group to represent an action, likelihood, and chance common config group.

The ActionLikelihoodChanceGroup constructor.

Parameters:
  • use – Whether to use the action or not.

  • likelihood – The likelihood of the action.

  • chance – The chance of the action.

  • doc – An optional descriptor.

Methods

get_config_elements

Get the attributes of the class that are either :class: ConfigGroup or ConfigItem.

get_non_config_elements

Get all attributes of the class that are not :class: ConfigGroup or :class: ConfigItem.

set_from_dict

Set the values of all :class: ConfigGroup or ConfigItem elements.

set_from_yaml

Set the elements of the group from a .yaml file.

stringify

Represent the class as a string.

to_dict

Return the ConfigGroup as a dict.

to_legacy_dict

Convert the group into a unitary depth dictionary of legacy config value (aliases) to :class: ConfigItem's.

to_yaml

Save the values of the elements of the group to a .yaml file.

validate

Validate the ActionLikelihoodChanceGroup.

validate_elements

Call the .validate() method on each of the elements in the group.

Attributes

config_groups

~yawning_titan.config.core.ConfigGroup children of the group.

config_items

~yawning_titan.config.core.ConfigItem children of the group.

validate()[source]#

Validate the ActionLikelihoodChanceGroup.

This is done at two levels:

1. A group level validation is performed that checks if likelihood and chance are provided when use is True. 2. An item level validation is performed by calling .validate on the use, likelihood, and chance config items.

Returns:

An instance of ConfigGroupValidation.

property config_groups#

~yawning_titan.config.core.ConfigGroup children of the group.

Type:

Property to represent the

Type:

class

property config_items#

~yawning_titan.config.core.ConfigItem children of the group.

Type:

Property to represent the

Type:

class

get_config_elements(types=None)#

Get the attributes of the class that are either :class: ConfigGroup or ConfigItem.

Parameters:

_type – An optional type for a specific type of config element.

Returns:

A dictionary of names to config elements.

get_non_config_elements()#

Get all attributes of the class that are not :class: ConfigGroup or :class: ConfigItem.

Returns:

A dictionary of names to attributes.

set_from_dict(config_dict, legacy=False, infer_legacy=False, **kwargs)#

Set the values of all :class: ConfigGroup or ConfigItem elements.

Parameters:
  • config_dict – A dictionary representing values of all config elements.

  • legacy – Whether to use the alias names for config elements to construct the config from a legacy dictionary.

  • infer_legacy – Attempt to recognise if a config is of a legacy type.

kwargs can contain 2 parameters:
  • root: Whether the element is a base level element or not.

    if the element is a root then it should validate all of its descendants.

  • legacy_lookup: The current flattened dictionary representation of the class by its legacy keys.

set_from_yaml(file_path, legacy=False, infer_legacy=False)#

Set the elements of the group from a .yaml file.

Parameters:
  • file_path – The path to the .yaml file.

  • legacy – Whether to use the alias names for config elements to construct the config from a legacy dictionary.

  • infer_legacy – Attempt to recognise if a config is of a legacy type.

stringify()#

Represent the class as a string.

Returns:

A string.

to_dict(values_only=False, legacy=False, include_none=True)#

Return the ConfigGroup as a dict.

Parameters:
  • values_only – Create a dictionary containing only the value of :class: ConfigItem’s

  • legacy – Convert the group into a unitary depth dictionary of legacy config value (aliases) to :class: ConfigItem’s by calling :method: ConfigGroup.to_legacy.

Returns:

The ConfigGroup as a dict.

to_legacy_dict(flattened_dict=None)#

Convert the group into a unitary depth dictionary of legacy config value (aliases) to :class: ConfigItem’s.

Returns:

a dictionary

to_yaml(file_path)#

Save the values of the elements of the group to a .yaml file.

Parameters:

file_path – The path to the .yaml file

validate_elements()#

Call the .validate() method on each of the elements in the group.