-
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
Incorrect representation of state vector with state.draw('latex') #13314
Comments
This is not an issue with displaying, but with the underlying value. Regardless of display method, the same value is displayed.
In [35]: state.draw('latex_source')
Out[35]: ' |0100\\rangle'
In [36]: statevector.draw('latex_source')
Out[36]: ' |1100\\rangle' And results for other inputs: def generate_bits(n: int):
yield from (bin(i)[2:].rjust(n, '0') for i in range(2**n))
for input_bits in generate_bits(3):
num_qubits = 4
circuit = QuantumCircuit(num_qubits)
cccx = XGate().control(num_ctrl_qubits=3, label=None, ctrl_state=input_bits)
circuit.x(2)
circuit.compose(cccx, range(num_qubits), inplace=True)
job = StatevectorSimulator().run(circuit)
state = job.result().get_statevector()
statevector = Statevector(circuit)
print(input_bits)
print(f"circuit state: {statevector.draw("latex_source")}")
print(f"result of run: {state.draw('latex_source')}")
print()
|
Environment
What is happening?
Wrong representation of the state vector after circuit execution when using
state.draw('latex')
function.How can we reproduce the issue?
When I run the following circuit
I do expect after state vector simulation to get
∣1100⟩
but instead
∣0100⟩
.What should happen?
So the community suggested trying another approach to display a state vector
and it works as expected
∣1100⟩
.Any suggestions?
Probably
state.draw('latex')
has an issue with displaying a state vector.The text was updated successfully, but these errors were encountered: