Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.19k stars 2.35k forks source link

Function to plot bloch sphere using Amplitude of States #6140

Open Arihant-Joshi opened 3 years ago

Arihant-Joshi commented 3 years ago

Currently, the plot_bloch_vector function can plot the Bloch sphere using spherical and cartesian coordinates.

I propose implementing an additional value of the coord_type parameter("dirac"??), which allows the user to plot the bloch sphere from the Amplitude of States. e.g. Given Qubit -> ∣ψ⟩ = α∣0⟩ + β∣1⟩ plot_bloch_vector([α, β], coord_type="dirac") would plot the corresponding Bloch Sphere.

Also, I already have created a function which does something similar while going through the qiskit textbook(it converts Dirac Notation to Spherical Coordinates and calls plot_bloch_vector), so I can quickly make required changes and raise a PR if this feature if found needed.

kdk commented 3 years ago

Hi @Arihant-Joshi , this seems like a nice extension (given that we already have multiple coord_types). Feel free to open a PR.

Arihant-Joshi commented 3 years ago

@kdk this PR is done with all checks passed. I've also added some error handling and warnings in case of different bloch[] list size, since this seems to be a user facing function. @nkanazawa1989 @nonhermitian

javabster commented 1 year ago

The original PR has been closed due to lack of response from original contributor and this issue is open again for new contributions. If anyone else would like to pick this work up please take a look at the old PR for ideas and remember to credit the original contributor if you use their implementation.