Skip to content

Commit

Permalink
fix(py): Set output cont for Conditionals (#1415)
Browse files Browse the repository at this point in the history
Missed this in #1400

drive-by: Improve the error message when a node does not have the output
count set.
  • Loading branch information
aborgna-q authored Aug 12, 2024
1 parent e7f9f4c commit 67bb8a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions hugr-py/src/hugr/cond_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ def new_nested(
def _update_outputs(self, outputs: TypeRow) -> None:
if self.parent_op._outputs is None:
self.parent_op._outputs = outputs
self.parent_node = self.hugr._update_node_outs(
self.parent_node, len(outputs)
)
else:
if outputs != self.parent_op._outputs:
msg = "Mismatched case outputs."
Expand Down
5 changes: 4 additions & 1 deletion hugr-py/src/hugr/node_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ def _index(
start = index.start or 0
stop = index.stop or self._num_out_ports
if stop is None:
msg = "Stop must be specified when number of outputs unknown"
msg = (
f"{self} does not have a fixed number of output ports. "
"Iterating over all output ports is not supported."
)
raise ValueError(msg)
step = index.step or 1
return (self[i] for i in range(start, stop, step))
Expand Down

0 comments on commit 67bb8a0

Please sign in to comment.