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
Running the below code triggered a qiskit.circuit.exceptions.CircuitError: "Invalid param type <class 'numpy.ndarray'> for gate unitary*1." I found this bug happens for some other Gates as well. Below is a minimal reproduction example using CUGate.
How can we reproduce the issue?
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit.circuit.library.standard_gates import CUGate
qr = QuantumRegister(2, name='qr')
cr = ClassicalRegister(2, name='cr')
qc = QuantumCircuit(qr, cr, name='qc')
qc.append(CUGate(0, 0, 0, 0).power(1).repeat(1), qargs=qr)
What should happen?
Traceback (most recent call last):
File "/mnt/tests/reproduction/reproduce_invalid_param_type.py", line 8, in <module>
qc.append(CUGate(0, 0, 0, 0).power(1).repeat(1), qargs=qr)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/envs/qiskit1.0.2/lib/python3.11/site-packages/qiskit/circuit/instruction.py", line 591, in repeat
instruction = self._return_repeat(n)
^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/envs/qiskit1.0.2/lib/python3.11/site-packages/qiskit/circuit/gate.py", line 87, in _return_repeat
return Gate(name=f"{self.name}*{exponent}", num_qubits=self.num_qubits, params=self.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/envs/qiskit1.0.2/lib/python3.11/site-packages/qiskit/circuit/gate.py", line 46, in __init__
super().__init__(name, num_qubits, 0, params, label=label, duration=duration, unit=unit)
File "/root/anaconda3/envs/qiskit1.0.2/lib/python3.11/site-packages/qiskit/circuit/instruction.py", line 108, in __init__
self.params = params # must be at last (other properties may be required for validation)
^^^^^^^^^^^
File "/root/anaconda3/envs/qiskit1.0.2/lib/python3.11/site-packages/qiskit/circuit/instruction.py", line 287, in params
self._params.append(self.validate_parameter(single_param))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/envs/qiskit1.0.2/lib/python3.11/site-packages/qiskit/circuit/gate.py", line 242, in validate_parameter
raise CircuitError(f"Invalid param type {type(parameter)} for gate {self.name}.")
qiskit.circuit.exceptions.CircuitError: "Invalid param type <class 'numpy.ndarray'> for gate unitary*1."
Any suggestions?
No response
The text was updated successfully, but these errors were encountered:
However, even though the UnitaryGate inherits from Gate, it doesn't include parameter name; so this fix should also involve unification of all Gate subclasses by parameters.
Environment
What is happening?
Running the below code triggered a qiskit.circuit.exceptions.CircuitError: "Invalid param type <class 'numpy.ndarray'> for gate unitary*1." I found this bug happens for some other Gates as well. Below is a minimal reproduction example using CUGate.
How can we reproduce the issue?
What should happen?
Any suggestions?
No response
The text was updated successfully, but these errors were encountered: