Skip to content

Commit

Permalink
Merge pull request #38 from dlyongemallo/static
Browse files Browse the repository at this point in the history
Pull out static function.
  • Loading branch information
dlyongemallo authored Apr 9, 2024
2 parents 7c7e4e3 + 4ead690 commit f1177c3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions zxpass/zxpass.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@
}


def _optimize(c: zx.Circuit) -> zx.Circuit:
g = c.to_graph()
zx.simplify.full_reduce(g)
return zx.extract.extract_circuit(g)


class ZXPass(TransformationPass):
"""This is a ZX transpiler pass using PyZX for circuit optimization.
Expand All @@ -99,12 +105,7 @@ def __init__(self, optimize: Optional[Callable[[zx.Circuit], zx.Circuit]] = None
self.qregs: OrderedDict[str, Qubit] = OrderedDict()
self.qubits: List[Qubit] = []
self.qubit_to_index: Dict[Qubit, int] = {}
self.optimize: Callable[[zx.Circuit], zx.Circuit] = optimize or self._optimize

def _optimize(self, c: zx.Circuit) -> zx.Circuit:
g = c.to_graph()
zx.simplify.full_reduce(g)
return zx.extract.extract_circuit(g)
self.optimize: Callable[[zx.Circuit], zx.Circuit] = optimize or _optimize

def _dag_to_circuits_and_nodes(self, dag: DAGCircuit) -> List[Union[zx.Circuit, DAGOpNode]]:
"""Convert a DAG to a list of PyZX Circuits and DAGOpNodes. As much of the DAG is converted to PyZX Circuits as
Expand Down

0 comments on commit f1177c3

Please sign in to comment.