update_for_dict(var_name, var_val, operation, glob_update, output)

when we evaluate an operation, we need to find pointers to that operation in globals and change that to the evaluated result. This code looks for that operation in a dictionary, and replaces the globals variable with a new dict containing the evaluated result

Source code in wt_ml/magic/operation.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
def update_for_dict(var_name, var_val, operation, glob_update, output):
    """
    when we evaluate an operation, we need to find pointers to that operation in globals
    and change that to the evaluated result. This code looks for that operation in a
    dictionary, and replaces the globals variable with a new dict containing the evaluated result
    """
    new_dict = dict()
    found = False
    for key, val in var_val.items():
        if key is operation:
            found = True
            key = output
        if val is operation:
            found = True
            val = output
        new_dict[key] = val
    if found:
        glob_update[var_name] = new_dict

update_for_sequence(var_name, var_val, operation, glob_update, output)

when we evaluate an operation, we need to find pointers to that operation in globals and change that to the evaluated result. This code looks for that operation in a sequence, and replaces the globals variable with a list containing the evaluated result

Source code in wt_ml/magic/operation.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
def update_for_sequence(var_name, var_val, operation, glob_update, output):
    """
    when we evaluate an operation, we need to find pointers to that operation in globals
    and change that to the evaluated result. This code looks for that operation in a
    sequence, and replaces the globals variable with a list containing the evaluated result
    """
    new_list = list()
    found = False
    for val in var_val:
        if val is operation:
            found = True
            val = output
        new_list.append(val)
    if found:
        glob_update[var_name] = new_list