You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
~/anaconda3/envs/qiskit_env/lib/python3.9/site-packages/qiskit/assembler/disassemble.py in _experiments_to_circuits(qobj)
128 _inst = instr_method(*params, qubits, clbits)
129 else:
--> 130 _inst = instr_method(*params, *qubits, *clbits)
131 elif name == 'bfunc':
132 conditional['value'] = int(i.val, 16)
TypeError: mcx() takes from 3 to 5 positional arguments but 6 were given
a shorter version that doesn't break the argument number also hints at what's being passed being incorrect in some way:
(same input as above except qc.mcx([0,1,2],3))
~/anaconda3/envs/qiskit_env/lib/python3.9/site-packages/qiskit/circuit/quantumcircuit.py in mcx(self, control_qubits, target_qubit, ancilla_qubits, mode)
2536 """
2537 from .library.standard_gates.x import MCXGrayCode, MCXRecursive, MCXVChain
-> 2538 num_ctrl_qubits = len(control_qubits)
2539
2540 available_implementations = {
TypeError: object of type 'Qubit' has no len()
What is the expected behavior?
correct disassembly into a circuit
Suggested solutions
I think what's happening here is that the signature for quantumcircuit.mcx expects a list of controls, followed by a target; mcx(control_qubits, target_qubit, ...) The qobj representation of an mcx gate is just a list of qubits, with (I think) the last being the target; L130 is unzipping the entire qubit list into the method, which does not match the signature.
granted, this might eventually be moot given #5897, but it looks like there needs to be another case in the disassembler for this gate and any like it that expect a list, or else a change in the gate def to accommodate this case.
The text was updated successfully, but these errors were encountered:
@ColemanCollins If you're not working on this, I think I have at least a rudimentary solution. It appears that 4 QuantumCircuit methods, mcx, mct, mcp, and mcu1 use the control_qubits list. (There may be others if we look through all the internally created gates, but I think fixing these will handle the immediate problem). It's easy to treat these as a special case in the disassembler.
Information
What is the current behavior?
When attempting to use
assembler.disassemble
on a Qobj with an mcx gate, the disassembler throws an error.Steps to reproduce the problem
produces
a shorter version that doesn't break the argument number also hints at what's being passed being incorrect in some way:
(same input as above except
qc.mcx([0,1,2],3)
)What is the expected behavior?
correct disassembly into a circuit
Suggested solutions
I think what's happening here is that the signature for quantumcircuit.mcx expects a list of controls, followed by a target;
mcx(control_qubits, target_qubit, ...)
The qobj representation of an mcx gate is just a list of qubits, with (I think) the last being the target; L130 is unzipping the entire qubit list into the method, which does not match the signature.granted, this might eventually be moot given #5897, but it looks like there needs to be another case in the disassembler for this gate and any like it that expect a list, or else a change in the gate def to accommodate this case.
The text was updated successfully, but these errors were encountered: