-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Closed
Copy link
Labels
bugSomething isn't workingSomething isn't working
Description
Environment
- Qiskit Terra version: 0.23.1
- Python version: 3.10.8
What is happening?
The quantum_info.Operator
constructor fails because of an unbound parameter while all the free parameters of the circuit seem to be properly bound.
How can we reproduce the issue?
from qiskit import QuantumCircuit
from qiskit.circuit import ParameterVector
from qiskit.circuit.library import RGate
pqc = QuantumCircuit(2)
xs = ParameterVector(name='x', length=2)
gate = RGate(*xs).control(num_ctrl_qubits=1)
pqc.append(gate, [0, 1])
pqc.draw('mpl')
from qiskit.quantum_info import Operator
qc = pqc.assign_parameters([2.34, 0.98])
op = Operator(qc)
TypeError: ParameterExpression with unbound parameters ({ParameterVectorElement(x[0])}) cannot be cast to a float.
What should happen?
The code above should work correctly. For other very similar parameterized quantum circuit (see the pqc
instance defined below), it runs as expected without any problem.
pqc = QuantumCircuit(3)
xs = ParameterVector(name='x', length=2)
gate = RGate(*xs).control(num_ctrl_qubits=2)
pqc.append(gate, [0, 1, 2])
Any suggestions?
I actually have no idea about why this is happening but it looks like a problem only related to controlled-gates with more than one parameter (e.g. CRGate, CUGate).
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working