Graph Parameters

This submodule handles the variable flow part of BLUMYCELIUM. This is what allows BLUMYCELIUM to derive the set of instructions necessary to compte a vriable.

Graph Parameters

class blumycelium.graph_parameters.CodeBlock(init_code=None, return_statement=None)[source]

a code block of python code to run

format(**string_kwargs)[source]

replace the name of variables by their myc_back_variables references

run(**myc_back_variables)[source]

run the code block

to_dict()[source]

return a dictionary version of the code block

exception blumycelium.graph_parameters.ExecutionError(code)[source]
class blumycelium.graph_parameters.GraphParameter(uid=None)[source]

A graph of Parameters

add_dependencies(*deps)[source]

add dependencies (other GraphParaemters) needed to compute the value

classmethod build_from_traversal(trav: dict, pull_origin_function=None)[source]

build a parameter from a traversal dictionary

make(visited_nodes=None, is_root=False)[source]

compute the value of the paraneter and return it

pp_traverse(full_representation=False, representation_attributes=['value', 'code_block'], print_it=True)[source]

a pretty print of the graph representation with dependencies

set_code_block(init_code, return_statement, **dependencies)[source]

set the code block of the parameter

set_origin(uid, pull_origin_function=None)[source]

set the origin (address) of the parameter and function to retreive the value from the origin

set_pull_origin_function(fct)[source]

set the function to pull jvalue form the origin

set_value(value)[source]

set the static value of the parameter

to_dict(reccursive=False, visited_nodes=None, copy_values=True)[source]

return a dict representation of the parameter recursively if asked to

traverse(visited_nodes=None, is_root=True, root_uid=None, to_dict=True)[source]

traverse the graph dependency tree and return a dictionary representing it

class blumycelium.graph_parameters.Value(*args, **kwargs)[source]

A wrapper for a graph parameter

make(force=False)[source]

compute a return the value represented by the Value object

pp_traverse(*args, **kwargs)[source]

pretty print the value and it’s dependencies

set_code_block(*args, **kwargs)[source]

set the code block to run

set_value(value)[source]

set the static value

to_dict(*args, **kwargs)[source]

return a dictionary representing the value

traverse(*args, **kwargs)[source]

return a dictionary representing the value and it’s dependencies