cutcutcodec.core.compilation.tree_to_graph.new_node

cutcutcodec.core.compilation.tree_to_graph.new_node(graph: MultiDiGraph, node: Node) tuple[str, dict[str]][source]

Compiles a node in an existing assembly graph context.

Parameters

graphnetworkx.MultiDiGraph

The graph on which we add the node.

nodecutcutcodec.core.classes.node.Node

The node that we want to name and extract properties.

Returns

namestr

The name of the node, this name is not already present in the graph.

attrsdict[str]

The attributes, the state of the node allowing to complete the graph.

Notes

The graph remains unchanged, it is only used for analysis.

Examples

>>> from pprint import pprint
>>> from cutcutcodec.core.classes.container import ContainerOutput
>>> from cutcutcodec.core.compilation.tree_to_graph import tree_to_graph, new_node
>>> from cutcutcodec.core.generation.audio.noise import GeneratorAudioNoise
>>> node = GeneratorAudioNoise(0)
>>> graph = tree_to_graph(ContainerOutput(node.out_streams))
>>> pprint(new_node(graph, node))
('generator_audio_noise_2',
 {'class': <class 'cutcutcodec.core.generation.audio.noise.GeneratorAudioNoise'>,
  'state': {'layout': 'stereo', 'seed': 0.0}})
>>>