priops.edge

priops.Edge

class priops.edge.Edge(input_node, output_node, weight=None, name=None)[source]

Edges describe connections between two Node objects. An edge has a direction; there is an input node and an output node.

An edge can be called, in that case the edge will transform an object list of the input node specification into an object list of the output node specification.

This class is abstract. Derived classes should provide:

  • .process(self, input): Processes the non-internode input data to non-internode output data. Non-internode data is different from internode data format by the fact that inter-node data is always a list, while intra-edge data might be scalar.
    1. If the input node is scalar, input will be scalar (the first element of the inter-node data stream). If the input node is not scalar, input will be the direct inter-node data stream.
    2. If the output node is scalar, .process() should return a scalar, which will then be converted by the output node to inter-node list format. If the output node is not scalar, the output of .process() should already be a list.
__init__(input_node, output_node, weight=None, name=None)[source]

input_node is the specification of the input, output_node is the specification of the output of the Edge. weight is the effort to follow this edge (default 1). name is used for pretty printing.

__str__()[source]
__add__(other_edge)[source]

Combines this edge self with another edge other_edge via creating a CombinedEdge instance.

__call__(inputs)[source]

Processes the inter-edge data stream inputs into inter-edge data stream outputs. Inter-edge data are lists.

Calls self.process() with appropriate arguments.

priops.IdentityEdge

class priops.edge.IdentityEdge(node)[source]

Bases: priops.edge.Edge

An edge with identical input and output nodes, returning its arguments on call. Has zero weight.

__init__(node)[source]

node is the node to process by identity.

process(input)[source]

Returns input unchanged.

priops.CombinedEdge

class priops.edge.CombinedEdge(constituents)[source]

Bases: priops.edge.Edge

Combined edges combine a number of Edge objects into one big edge. The input node of the combined edge is the sum of all input nodes of the constituets. The output node of a combined edge is similarly the sum of all output nodes of the constituets.

When being called, the combined edge dispatches the inputs to the constituents according to the length of their input nodes. Then the constituents will be called with the dispatched inputs.

__init__(constituents)[source]

Combines constituents into a combined egde.

process(input)[source]

Dispatches the input object list input to the constituents.

Table Of Contents

Previous topic

priops.node

Next topic

priops.path

This Page