Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: cleanups from writing docstring #1232

Merged
merged 7 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hugr-py/src/hugr/dfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def _fn_sig(self, func: ToNode) -> PolyFuncType:

def _wire_up(self, node: Node, ports: Iterable[Wire]) -> TypeRow:
tys = [self._wire_up_port(node, i, p) for i, p in enumerate(ports)]
if isinstance(op := self.hugr[node].op, ops.PartialOp):
if isinstance(op := self.hugr[node].op, ops._PartialOp):
op.set_in_types(tys)
return tys

Expand Down
5 changes: 0 additions & 5 deletions hugr-py/src/hugr/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,3 @@ def msg(self):

class ParentBeforeChild(Exception):
msg: str = "Parent node must be added before child node."


@dataclass
class IncompleteOp(Exception):
msg: str = "Operation is incomplete, may require set_in_types to be called."
6 changes: 3 additions & 3 deletions hugr-py/src/hugr/hugr.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class NodeData:
_num_outs: int = 0
children: list[Node] = field(default_factory=list)

def to_serial(self, node: Node, hugr: Hugr) -> SerialOp:
o = self.op.to_serial(node, self.parent if self.parent else node, hugr)
def to_serial(self, node: Node) -> SerialOp:
o = self.op.to_serial(self.parent if self.parent else node)

return SerialOp(root=o) # type: ignore[arg-type]

Expand Down Expand Up @@ -297,7 +297,7 @@ def _serialise_link(
return SerialHugr(
version="v1",
# non contiguous indices will be erased
nodes=[node.to_serial(Node(idx), self) for idx, node in enumerate(node_it)],
nodes=[node.to_serial(Node(idx)) for idx, node in enumerate(node_it)],
edges=[_serialise_link(link) for link in self._links.items()],
)

Expand Down
Loading
Loading