-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Circuit is failed to visualize or execute when adding a cx gate with label
=1
#8036
Comments
Thanks for the report! By coincidence, we've actually merged the type checking you've suggested in #7671, which will be released as part of Qiskit Terra 0.21 in around a couple of months. The output of your example now is: >>> from qiskit import QuantumCircuit
>>> raw_circuit = QuantumCircuit(2)
>>> raw_circuit.cx(0, 1, 1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/jake/code/qiskit/terra/qiskit/circuit/quantumcircuit.py", line 3706, in cx
CXGate(label=label, ctrl_state=ctrl_state), [control_qubit, target_qubit], []
File "/Users/jake/code/qiskit/terra/qiskit/circuit/library/standard_gates/x.py", line 186, in __init__
super().__init__(
File "/Users/jake/code/qiskit/terra/qiskit/circuit/controlledgate.py", line 95, in __init__
super().__init__(name, num_qubits, params, label=label)
File "/Users/jake/code/qiskit/terra/qiskit/circuit/gate.py", line 38, in __init__
super().__init__(name, num_qubits, 0, params, label=label)
File "/Users/jake/code/qiskit/terra/qiskit/circuit/instruction.py", line 91, in __init__
raise TypeError("label expects a string or None")
TypeError: label expects a string or None |
Thanks for your reply!I still have no idea about why it failed in simulation step,can you give me some advice? |
The simulation likely succeeded, except you asked for the counts and there's no qc = QuantumCircuit(2, 2)
qc.cx(0, 1)
qc.measure([0, 1], [0, 1]) and then do your transpilation and |
I'm very sorry that I gave the wrong program,the real program that will cause
|
You should remove the incorrect |
Informations
What is the current behavior?
Assigning an Integer value
1
to the argumentlabel
ofcx
gate will cause abnormal behavior.Steps to reproduce the problem
If I assign an Integer value
1
to the argumentlabel
, Qiskit fails to draw the circuit and throws anAttributeError
. It can be reproduced by running the following test case:The error message is shown below:
The code snippet to trigger this error is in the
Bullet
class of text.py as follows:If the argument
label
is set to be more than1
, it will assign the value oflabel
toself.top_connect
, but iflabel
is set to be0
, it will not do this.After this assignment, once the program try to visit the attribute 'center' in an 'int' type, it will wrong.In addition, when running the compiled circuit as shown the following test case, Qiskit outputs an empty result.
A
QiskitError
is thrown as below:After I debugged the whole process, I find that it may be occurred when calling an extra cyphon code, which try to execute the
cx
gate.Suggested solutions
Maybe a type check for argument
label
will be helpful.The text was updated successfully, but these errors were encountered: