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

Make plot_state automatically convert state vectors to density matrices #907

Closed
chriseclectic opened this Issue Sep 17, 2018 · 0 comments

Comments

1 participant
@chriseclectic
Member

chriseclectic commented Sep 17, 2018

What is the expected enhancement?

When calling the plot_state visualization function the input must be a density matrix, however the statevector simulator returns a state vector that must be manually converted to a density matrix. This should be done automatically when a user calls plot_state(statevector):

Expected use:

import qiskit
from qiskit.tools.visualization import plot_state
qr = qiskit.QuantumRegister(2)
circ = qiskit.QuantumCircuit(qr)
circ.h(qr[0])
circ.cx(qr[0], qr[1])
result = qiskit.execute(circ, 'local_statevector_simulator).result()
state = result.get_statevector(circ)
fig = plot_state(state)
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment