Nodes define nodes in the graph, by giving a specification of a list of objects. A node contains a list, each element describes the category of an operand. (For technical reason if cannot be a list: Overloading __getitem__() in that case doesn’t work.)
This class is abstract. Derived classes should provide:
Initialises the Node from either one item or many items. One of item or items must be given, but not both. If both item and items are None, it is assumed that item is given as None, and that items is not specified.
Alternatively, the Node can be initialised from another Node instance node. This is needed by derived classes in some cases to provide e.g. slicing operations based on this class’es slicing operation. If node is given, it overrides all other parameters.
Processes given data to match the scalar/vector specification of the node. This is defined at initialisation time.
data is always assumed to be a list. If self is scalar, the length must be unity, and the first element is returned. Else, the list is returned unchanged.
Processes the output of an edge according to the scalar/vector specification of the node to match the inter-node data flow specification (which is lists).
If self is scalar, the data is wrapped into a list, else, the data is returned unchanged.
Combines two nodes by combining them into a CombinedNode.
Bases: priops.node.Node
A node without elements. Needed as initial element for summing up nodes via sum().
Returns the other node other_node, since this node is empty and doesn’t matter.
Bases: priops.node.Node
Combined nodes combine a number of Node objects into one big node. The elements of the combined node are the sum of all constituents, seeing the constituents as list objects.
If a combined node fulfils another specification depends on the constituents.