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

Fixes disassembler error for mcx gate #6291

Merged
merged 7 commits into from
Apr 24, 2021
Merged
Show file tree
Hide file tree
Changes from all 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: 2 additions & 0 deletions qiskit/assembler/disassemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ def _experiments_to_circuits(qobj):
_inst = instr_method(params, qubits)
elif i.name == 'isometry':
_inst = instr_method(*params, qubits, clbits)
elif i.name in ['mcx', 'mcu1', 'mcp']:
_inst = instr_method(*params, qubits[:-1], qubits[-1], *clbits)
else:
_inst = instr_method(*params, *qubits, *clbits)
elif name == 'bfunc':
Expand Down
15 changes: 15 additions & 0 deletions test/python/compiler/test_disassembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,21 @@ def test_circuit_with_simple_conditional(self):
self.assertEqual(circuits[0], qc)
self.assertEqual({}, header)

def test_circuit_with_mcx(self):
"""Verify disassemble handles mcx gate - #6271."""
qr = QuantumRegister(5)
cr = ClassicalRegister(5)
qc = QuantumCircuit(qr, cr)
qc.mcx([0, 1, 2], 4)
qobj = assemble(qc)
circuits, run_config_out, header = disassemble(qobj)
run_config_out = RunConfig(**run_config_out)
self.assertEqual(run_config_out.n_qubits, 5)
self.assertEqual(run_config_out.memory_slots, 5)
self.assertEqual(len(circuits), 1)
self.assertEqual(circuits[0], qc)
self.assertEqual({}, header)

def test_multiple_conditionals_multiple_registers(self):
"""Verify disassemble handles multiple conditionals and registers."""
qr = QuantumRegister(3)
Expand Down