quantum-viz
quantum-viz is the Python package companion of quantum-viz.js, a JavaScript package that supports visualizing any arbitrary quantum gate, classical control logic and collapsed grouped blocks of gates using JSON-formatted input data. quantum-viz contains a Jupyter widget and will also include support for translating quantum circuits written in common quantum programming libraries to JSON using the quantum-viz.js JSON schema.
Installation
You can install the quantum-viz.js widget via pip from PyPI:
pip install quantum-viz
Example
To use the quantum-viz widget, run the below example code in a Jupyter notebook cell:
from quantum_viz import Viewer
# Create a quantum circuit that prepares a Bell state
circuit = {
"qubits": [{ "id": 0 }, { "id": 1, "numChildren": 1 }],
"operations": [
{
"gate": 'H',
"targets": [{ "qId": 0 }],
},
{
"gate": 'X',
"isControlled": "True",
"controls": [{ "qId": 0 }],
"targets": [{ "qId": 1 }],
},
{
"gate": 'Measure',
"isMeasurement": "True",
"controls": [{ "qId": 1 }],
"targets": [{ "type": 1, "qId": 1, "cId": 0 }],
},
],
}
widget = Viewer(circuit)
widget # Display the widget
Qiskit Integration
By installing the optional [qiskit] dependency, you can leverage Qiskit's QuantumCircuit APIs
to define the circuit and render it using the Viewer widget on Jupyter, for example:
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from quantum_viz import Viewer
qr = QuantumRegister(3, 'q')
anc = QuantumRegister(1, 'ancilla')
cr = ClassicalRegister(3, 'c')
qc = QuantumCircuit(qr, anc, cr)
qc.h(qr[0:3])
qc.x(anc[0])
qc.h(anc[0])
qc.cx(qr[0:3], anc[0])
qc.h(qr[0:3])
qc.barrier(qr)
qc.measure(qr, cr)
Viewer(qc)
Optionally, you can also import the display method from quantum_viz.utils to render the circuit on a new browser window:
from quantum_viz.utils import display
display(qc)
Contributing
Check out our contributing guidelines to find out how you can contribute to quantum-viz.
Metadata
Release files for quantum-viz 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| quantum-viz-1.0.5.tar.gz | 10.1 kB | Without provenance | Details for quantum-viz-1.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| quantum_viz-1.0.5-py3-none-any.whl | Python 3 | none | any | Details for quantum_viz-1.0.5-py3-none-any.whl |
Total release size: 20.5 kB
Release files / quantum-viz-1.0.5.tar.gz
| Download URL | quantum-viz-1.0.5.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e6214317e5dcc370b732613e2bfb895b864d1740a2a9dd70c3e09551d75f6dd
|
|
BLAKE2b-256 checksum How to use checksums |
a1d6289988da97b49b6bf169e3eb75491a1c1f3c08d4966d0805d1a6e6903cc5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.12
|
Release files / quantum_viz-1.0.5-py3-none-any.whl
| Download URL | quantum_viz-1.0.5-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f3df8132577c1640277b167949f7418cd766074a79ee20dca4bdc265dca7853b
|
|
BLAKE2b-256 checksum How to use checksums |
5dee11b61a3434aa0bf65fed834496a23235f8de63bd133261942f6c9d828797
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.12
|
Security for quantum-viz 1.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.