-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into ab/list-ops
- Loading branch information
Showing
24 changed files
with
145 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"""Classes for building HUGRs.""" | ||
|
||
from .base import ParentBuilder | ||
from .cfg import Block, Cfg | ||
from .cond_loop import Case, Conditional, If, TailLoop | ||
from .dfg import DefinitionBuilder, DfBase, Dfg, Function | ||
from .function import Module | ||
from .tracked_dfg import TrackedDfg | ||
|
||
__all__ = [ | ||
"ParentBuilder", | ||
"Cfg", | ||
"Block", | ||
"Case", | ||
"If", | ||
"Conditional", | ||
"TailLoop", | ||
"Function", | ||
"Module", | ||
"TrackedDfg", | ||
"Dfg", | ||
"DefinitionBuilder", | ||
"DfBase", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""Base classes for HUGR builders.""" | ||
|
||
from __future__ import annotations | ||
|
||
from typing import ( | ||
Protocol, | ||
cast, | ||
) | ||
|
||
from hugr.hugr.base import Hugr, OpVar | ||
from hugr.hugr.node_port import ( | ||
Node, | ||
ToNode, | ||
) | ||
|
||
|
||
class ParentBuilder(ToNode, Protocol[OpVar]): | ||
"""Abstract interface implemented by builders of nodes that contain child HUGRs.""" | ||
|
||
#: The child HUGR. | ||
hugr: Hugr[OpVar] | ||
# Unique parent node. | ||
parent_node: Node | ||
|
||
def to_node(self) -> Node: | ||
return self.parent_node | ||
|
||
@property | ||
def parent_op(self) -> OpVar: | ||
"""The parent node's operation.""" | ||
return cast(OpVar, self.hugr[self.parent_node].op) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
"""The main HUGR structure.""" | ||
|
||
from .base import Hugr, NodeData | ||
from .node_port import ( | ||
Direction, | ||
InPort, | ||
Node, | ||
OutPort, | ||
Wire, | ||
) | ||
|
||
__all__ = [ | ||
"Hugr", | ||
"NodeData", | ||
"Direction", | ||
"InPort", | ||
"Wire", | ||
"OutPort", | ||
"Node", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import pytest | ||
|
||
from hugr.node_port import Node, OutPort | ||
from hugr.hugr import Node, OutPort | ||
|
||
|
||
def test_index(): | ||
|
Oops, something went wrong.