Skip to content

opto.features.priority_search.utils

get_original_name

get_original_name(node)

Extract the original name from a node, removing all _copy suffixes.

is_node_copy

is_node_copy(a, b)

Check if two nodes are copies of each other by comparing their original names.

This function has transitivity: if A is a copy of B and B is a copy of C, then A is also considered a copy of C.

is_module_copy

is_module_copy(a, b)

Check if a and b (trace.Modules) are copies of each other.

remap_update_dict

remap_update_dict(base_module, update_dict)

Remap the update dict to the agent's parameters. update_dict might have keys which are copies of the base_module's parameters or visa versa. This function remaps the keys in update_dict to the original parameters of the base_module.

The return dict is empty if no keys in update_dict matched any parameters of the base_module. This condition can be used to check if the update_dict contains non-trivial updates.

set_module_parameters

set_module_parameters(agent, update_dict)

Set the parameters of the agent based on the update_dict. The update_dict is a dictionary of ParameterNode: value pairs. The agent's parameters will be updated with the values from the update_dict.

create_module_from_update_dict

create_module_from_update_dict(agent, update_dict)

Create a new agent from the update_dict. The update_dict is a dictionary of ParameterNode: value pairs. A new agent will be created with the parameters set to the values from the update_dict.