graph.GraphHolder
- class graph.GraphHolder(input_nodes: SetList[GraphNode], output_nodes: SetList[GraphNode], name: str, computational_module: Any)[source]
Bases:
GraphModuleBaseA
GraphModulethat encapsulates other graphsThis module is used to simply encapsulate a graph, and has no computational function. This module can be removed from the graph by wiring up its submodules directly, without modifying the computational structure of the graph.
GraphHoldermodules contain onlyinput_nodesandinput_nodesattributes that are connected to other modules. AGraphHoldermodule should never be the sink or source of aGraphNode.See also
Use the
as_GraphHolder()helper function to encapsulate anotherGraphModule.For an overview of computational graphs in Rockpool, see Computational graphs in Rockpool.
Attributes overview
The input nodes attached to this module
The output nodes attached to this module
An arbitrary name attached to this specific
GraphModuleThe computational module that acts as the source for this graph module
Methods overview
__init__(input_nodes, output_nodes, name, ...)add_input(node)Add a
GraphNodeas an input source to this moduleadd_output(node)Add a
GraphNodeas an output of this moduleRemove all
GraphNodes as inputs of this moduleRemove all
GraphNodes as outputs of this moduleremove_input(node)Remove a
GraphNodeas an input of this moduleremove_output(node)Remove a
GraphNodeas an output of this module- __init__(input_nodes: SetList[GraphNode], output_nodes: SetList[GraphNode], name: str, computational_module: Any) None
- classmethod _factory(size_in: int, size_out: int, name: str | None = None, computational_module: Any | None = None, *args, **kwargs) GraphModuleBase
Build a new
GraphModuleorGraphModulesubclass, with new input and outputGraphNodes created automaticallyUse this factory method to construct a new
GraphModulefrom scratch, which needs new input and outputGraphNodes created automatically. This helper method will be inherited by newGraphModulesubclasses, and will act as factory methods also for your customGraphModulesubclass.- Parameters:
size_in (int) – The number of input
GraphNodes to create and attachsize_out (int) – The number of output
GraphNodes to create and attachname (str, optional) – An arbitrary name to attach to this
GraphModule, defaults to Nonecomputational_module (Optional[Module], optional) – A rockpool computational module that forms the “generator” of this graph module, defaults to None
- Returns:
The newly constructed
GraphModuleorGraphModulesubclass- Return type:
- add_input(node: GraphNode) None
Add a
GraphNodeas an input source to this module- Parameters:
node (GraphNode) – The node to add as an input source. This node will be appended after the last current input node.
- add_output(node: GraphNode) None
Add a
GraphNodeas an output of this module- Parameters:
node (GraphNode) – The node to add as an output channel. This node will be appended after the last current output node.
- computational_module: Any
The computational module that acts as the source for this graph module
- Type:
- name: str
An arbitrary name attached to this specific
GraphModule- Type:
str