Skip to content

Commit

Permalink
refactor: cleanups from writing docstring (#1232)
Browse files Browse the repository at this point in the history
go commit by commit
mostly things like making methods/classes internal
  • Loading branch information
ss2165 authored Jun 28, 2024
1 parent 320a9a7 commit 80b8a85
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 118 deletions.
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

0 comments on commit 80b8a85

Please sign in to comment.