@@ -1552,6 +1552,40 @@ def inputs(self, _: Any) -> None:
1552
1552
"Directly mutating the input sequence is unsupported. Please use Node.replace_input_with() instead."
1553
1553
)
1554
1554
1555
+ @property
1556
+ def outputs (self ) -> Sequence [Value ]:
1557
+ """The output values of the node.
1558
+
1559
+ The outputs are immutable. To change the outputs, create a new node and
1560
+ replace the inputs of the using nodes of this node's outputs by calling
1561
+ :meth:`replace_input_with` on the using nodes of this node's outputs.
1562
+ """
1563
+ return self ._outputs
1564
+
1565
+ @outputs .setter
1566
+ def outputs (self , _ : Sequence [Value ]) -> None :
1567
+ raise AttributeError ("outputs is immutable. Please create a new node instead." )
1568
+
1569
+ def i (self , index : int = 0 ) -> Value | None :
1570
+ """Get the input value at the given index.
1571
+
1572
+ This is a convenience method that is equivalent to `self.inputs[index]`.
1573
+
1574
+ Raises:
1575
+ IndexError: If the index is out of range.
1576
+ """
1577
+ return self .inputs [index ]
1578
+
1579
+ def o (self , index : int = 0 ) -> Value :
1580
+ """Get the output value at the given index.
1581
+
1582
+ This is a convenience method that is equivalent to `self.outputs[index]`.
1583
+
1584
+ Raises:
1585
+ IndexError: If the index is out of range.
1586
+ """
1587
+ return self .outputs [index ]
1588
+
1555
1589
def predecessors (self ) -> Sequence [Node ]:
1556
1590
"""Return the predecessor nodes of the node, deduplicated, in a deterministic order."""
1557
1591
# Use the ordered nature of a dictionary to deduplicate the nodes
@@ -1622,20 +1656,6 @@ def append(self, /, nodes: Node | Iterable[Node]) -> None:
1622
1656
raise ValueError ("The node to append to does not belong to any graph." )
1623
1657
self ._graph .insert_after (self , nodes )
1624
1658
1625
- @property
1626
- def outputs (self ) -> Sequence [Value ]:
1627
- """The output values of the node.
1628
-
1629
- The outputs are immutable. To change the outputs, create a new node and
1630
- replace the inputs of the using nodes of this node's outputs by calling
1631
- :meth:`replace_input_with` on the using nodes of this node's outputs.
1632
- """
1633
- return self ._outputs
1634
-
1635
- @outputs .setter
1636
- def outputs (self , _ : Sequence [Value ]) -> None :
1637
- raise AttributeError ("outputs is immutable. Please create a new node instead." )
1638
-
1639
1659
@property
1640
1660
def attributes (self ) -> OrderedDict [str , Attr ]:
1641
1661
"""The attributes of the node."""
0 commit comments