mirror of https://github.com/Qiskit/qiskit.git
* Fixes #2858 by checking the entire instruction for classical registers, not just the first gate in it. * lint decompose.py * Update unroll_3q_or_more.py * lint unroller.py
This commit is contained in:
parent
de5a2a613a
commit
16dcbe259b
|
@ -49,9 +49,12 @@ class Decompose(TransformationPass):
|
|||
# hacky way to build a dag on the same register as the rule is defined
|
||||
# TODO: need anonymous rules to address wires by index
|
||||
decomposition = DAGCircuit()
|
||||
decomposition.add_qreg(rule[0][1][0].register)
|
||||
if rule[0][2]:
|
||||
decomposition.add_creg(rule[0][2][0].register)
|
||||
qregs = {qb.register for inst in rule for qb in inst[1]}
|
||||
cregs = {cb.register for inst in rule for cb in inst[2]}
|
||||
for qreg in qregs:
|
||||
decomposition.add_qreg(qreg)
|
||||
for creg in cregs:
|
||||
decomposition.add_creg(creg)
|
||||
for inst in rule:
|
||||
decomposition.apply_operation_back(*inst)
|
||||
dag.substitute_node_with_dag(node, decomposition)
|
||||
|
|
|
@ -46,7 +46,12 @@ class Unroll3qOrMore(TransformationPass):
|
|||
# hacky way to build a dag on the same register as the rule is defined
|
||||
# TODO: need anonymous rules to address wires by index
|
||||
decomposition = DAGCircuit()
|
||||
decomposition.add_qreg(rule[0][1][0].register)
|
||||
qregs = {qb.register for inst in rule for qb in inst[1]}
|
||||
cregs = {cb.register for inst in rule for cb in inst[2]}
|
||||
for qreg in qregs:
|
||||
decomposition.add_qreg(qreg)
|
||||
for creg in cregs:
|
||||
decomposition.add_creg(creg)
|
||||
for inst in rule:
|
||||
decomposition.apply_operation_back(*inst)
|
||||
decomposition = self.run(decomposition) # recursively unroll
|
||||
|
|
|
@ -75,7 +75,12 @@ class Unroller(TransformationPass):
|
|||
# hacky way to build a dag on the same register as the rule is defined
|
||||
# TODO: need anonymous rules to address wires by index
|
||||
decomposition = DAGCircuit()
|
||||
decomposition.add_qreg(rule[0][1][0].register)
|
||||
qregs = {qb.register for inst in rule for qb in inst[1]}
|
||||
cregs = {cb.register for inst in rule for cb in inst[2]}
|
||||
for qreg in qregs:
|
||||
decomposition.add_qreg(qreg)
|
||||
for creg in cregs:
|
||||
decomposition.add_creg(creg)
|
||||
for inst in rule:
|
||||
decomposition.apply_operation_back(*inst)
|
||||
|
||||
|
|
Loading…
Reference in New Issue