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
Operating system: Linux-3.10.0-957.el7.x86_64-x86_64-with-glibc2.10
OS printed using platform.platform
What is happening?
Error
RuntimeError Traceback (most recent call last)
File [~/.conda/envs/ibm_q/lib/python3.8/site-packages/qiskit/circuit/parameterexpression.py:474]/~/.conda/envs/ibm_q/lib/python3.8/site-packages/qiskit/circuit/parameterexpression.py:474, in ParameterExpression.__float__(self)
/.conda/envs/ibm_q/lib/python3.8/site-packages/qiskit/circuit/parameterexpression.py:473 try:
/.conda/envs/ibm_q/lib/python3.8/site-packages/qiskit/circuit/parameterexpression.py:474 return float(self._symbol_expr)
/.conda/envs/ibm_q/lib/python3.8/site-packages/qiskit/circuit/parameterexpression.py:475 # TypeError is for sympy, RuntimeError for symengine
File symengine_wrapper.pyx:1151, in symengine.lib.symengine_wrapper.Basic.__float__()
File symengine_wrapper.pyx:976, in symengine.lib.symengine_wrapper.Basic.n()
File symengine_wrapper.pyx:4346, in symengine.lib.symengine_wrapper.evalf()
RuntimeError: Symbol cannot be evaluated.
The above exception was the direct cause of the following exception:
TypeError Traceback (most recent call last)
[/qrl/test.ipynb/qrl/test.ipynb) Cell 19 line 1
line=9 theta = Parameter("theta")
line=11 circuit.x(0)
line=12 cos_val = cos(float(theta) [/] 2)
line=13 sin_val = -1j * sin(float(theta) [/] 2)
line=14 circuit.data.insert(
line=15 0,
line=16 CircuitInstruction(
(...)
line=26 ),
line=27 )
File [~/.conda/envs/ibm_q/lib/python3.8/site-packages/qiskit/circuit/parameterexpression.py:477/qrl/~/.conda/envs/ibm_q/lib/python3.8/site-packages/qiskit/circuit/parameterexpression.py:477), in ParameterExpression.__float__(self)
/qrl/~/.conda/envs/ibm_q/lib/python3.8/site-packages/qiskit/circuit/parameterexpression.py:475) # TypeError is for sympy, RuntimeError for symengine
/qrl/~/.conda/envs/ibm_q/lib/python3.8/site-packages/qiskit/circuit/parameterexpression.py:476) except (TypeError, RuntimeError) as exc:
--> /qrl/~/.conda/envs/ibm_q/lib/python3.8/site-packages/qiskit/circuit/parameterexpression.py:477) raise TypeError(
/qrl/~/.conda/envs/ibm_q/lib/python3.8/site-packages/qiskit/circuit/parameterexpression.py:478) "ParameterExpression with unbound parameters ({}) "
/qrl/~/.conda/envs/ibm_q/lib/python3.8/site-packages/qiskit/circuit/parameterexpression.py:479) "cannot be cast to a float.".format(self.parameters)
/qrl/~/.conda/envs/ibm_q/lib/python3.8/site-packages/qiskit/circuit/parameterexpression.py:480) ) from exc
TypeError: ParameterExpression with unbound parameters ({Parameter(theta)}) cannot be cast to a float.
We do not support symbolic manipulation of dense matrices in Qiskit and have no plans to add such support. You can look at community-driven packages such as qiskit-symb for that kind of capability.
I would note that the gate you're trying to add is a controlled X rotation, which is (in theory) supported by the RXGate(theta).control() object or the QuantumCircuit.crx method. I think at the moment that there's a potential bug in that (see #10311 and linked issues). Your code is also using several low-level internal objects, and using them incorrectly:
You should not attempt to modify QuantumCircuit.data directly like that.
CircuitInstruction is a low-level object that you largely should not need to use.
The operation field of CircuitInstruction must be an instance of qiskit.circuit.Operation, not qiskit.quantum_info.Operator which is something entirely different.
I'll close this issue as "solved" now, since I don't think there's anything more to do from the Qiskit side. Please feel free to re-open if there's more to discuss.
Environment
OS printed using platform.platform
What is happening?
Error
How can we reproduce the issue?
Code:
What should happen?
Unbound Parameter error, originally initiated due to symengine
Any suggestions?
How do I create a Parameterised Gate from unitary matrix
The text was updated successfully, but these errors were encountered: