ToNode#

class hugr.hugr.node_port.ToNode(*args, **kwargs)[source]#

Bases: Wire, Protocol

Protocol by any object that can be treated as a Node.

Methods

inp

Generate an input port for this node.

out

Generate an output port for this node.

out_port

OutPort corresponding to this Wire.

outputs

Returns an iterator over the output ports of this node.

port

Generate a port in direction for this node with offset.

to_node

Convert to a Node.

Attributes

metadata

Metadata associated with this node.

inp(offset: int) InPort[source]#

Generate an input port for this node.

Parameters:

offset – port offset.

Returns:

Incoming port for this node.

Examples

>>> Node(0).inp(1)
InPort(Node(0), 1)
property metadata: dict[str, object]#

Metadata associated with this node.

out(offset: int) OutPort[source]#

Generate an output port for this node.

Parameters:

offset – port offset.

Returns:

Outgoing port for this node.

Examples

>>> Node(0).out(1)
OutPort(Node(0), 1)
out_port() OutPort[source]#

OutPort corresponding to this Wire.

outputs() Iterator[OutPort][source]#

Returns an iterator over the output ports of this node.

port(offset: int, direction: Direction) InPort | OutPort[source]#

Generate a port in direction for this node with offset.

Examples

>>> Node(0).port(1, Direction.INCOMING)
InPort(Node(0), 1)
>>> Node(0).port(1, Direction.OUTGOING)
OutPort(Node(0), 1)
to_node() Node[source]#

Convert to a Node.