mirror of https://github.com/Qiskit/qiskit.git
Fix bug in circuit decompose (#8364)
* fix bug in circuit decompose * add test * Update test/python/circuit/test_circuit_operations.py Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
6dd0d69ec9
commit
77535607f9
|
@ -128,9 +128,7 @@ class Decompose(TransformationPass):
|
|||
node.name in gates or any(fnmatch(node.name, p) for p in strings_list)
|
||||
):
|
||||
return True
|
||||
elif not has_label and ( # check if Gate type given
|
||||
any(isinstance(node.op, op) for op in gate_type_list)
|
||||
):
|
||||
elif any(isinstance(node.op, op) for op in gate_type_list): # check if Gate type given
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
fixes:
|
||||
- Fixed a bug in :meth:`.QuantumCircuit.decompose` that caused the
|
||||
`gates_to_decompose` argument to be handled incorrectly.
|
|
@ -1265,3 +1265,10 @@ class TestCircuitPrivateOperations(QiskitTestCase):
|
|||
instruction = test._pop_previous_instruction_in_scope()
|
||||
self.assertEqual(list(last_instructions), [instruction])
|
||||
self.assertEqual({y}, set(test.parameters))
|
||||
|
||||
def test_decompose_gate_type(self):
|
||||
"""Test decompose specifying gate type."""
|
||||
circuit = QuantumCircuit(1)
|
||||
circuit.append(SGate(label="s_gate"), [0])
|
||||
decomposed = circuit.decompose(gates_to_decompose=SGate)
|
||||
self.assertNotIn("s", decomposed.count_ops())
|
||||
|
|
Loading…
Reference in New Issue