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

exception NodeOperationError[source]

Bases: Exception

find_relatives(node_or_nodes, constraint_key, why_desc='<purpose not specified>')[source]
Parameters:
  • node_or_nodes – a node or iterable of nodes to start the search.

  • constraint_key

    1. callable to filter nodes by or

    2. type spec to be used with isinstance.

  • 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, 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

    1. callable to filter nodes by or

    2. type to be used with isinstance.

  • 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)[source]

Recursively return nodes connected to the specified node_set.

Parameters:

node_set – iterable collection of nodes (list, tuple, set,…)

Returns:

set of nodes with some relationship to the input set.