node_functions module
Full Documentation for hippynn.graphs.nodes.base.node_functions
module.
Click here for a summary page.
Base node definition.
- exception NodeAmbiguityError[source]
Bases:
NodeOperationError
- exception NodeNotFound[source]
Bases:
NodeOperationError
- find_relatives(node_or_nodes, constraint_key, ancestors=True, descendants=True, why_desc='<purpose not specified>')[source]
- Parameters:
node_or_nodes – a node or iterable of nodes to start the search.
constraint_key –
callable to filter nodes by or
type spec to be used with isinstance.
ancestors – whether to search ancestors of the node set
descendants – whether to search descendants of the node set
why_desc – If a node cannot be found satisfying the constraint, raise an error with this message.
- Returns:
set of nodes related to this node that obey a constraint
- find_unique_relative(node_or_nodes, constraint, ancestor_fallback=True, why_desc='<purpose not specified>')[source]
Look for a unique parent or child node type in the graph connected to the starting node.
- Parameters:
node_or_nodes – a node or iterable of nodes to start the search.
constraint –
callable to filter nodes by or
type to be used with isinstance.
ancestor_fallback – This sets whether or not a unique relative in only the ancestors is acceptable. If set to true, and multiple nodes are found, the search will be run again with only the ancestors of the initial node set.
why_desc – specification of error message
- Returns:
Node compatible with constraint.
Note
If no node is found, a NodeNotFoundError is rasied. If more than one node is found, a NodeambiguityError is raised.
- get_connected_nodes(node_set, ancestors=True, descendants=True)[source]
Recursively return nodes connected to the specified node_set.
- Parameters:
node_set – iterable collection of nodes (list, tuple, set,…)
ancestors – whether to search ancestors of the node set
descendants – whether to search descendants of the node set
- Returns:
set of nodes with some relationship to the input set.