A Qiskit visualize extension
Project description
Qiskit StateVector extension
A simple Qiskit StateVector extension with more visualization function:
- Modifies the original StateVector visualization, adds line break and alignment.
- StateVector visualization with x, y, z basis.
- StateVector measurement with x, y, z basis, and visualizes all the possible measurement result.
- Visualizes the vector of a StateVector and the unitary matrix of a QuantumCircuit as a visually pleasing matrix in LaTeX format.
- Uses textbook qubit order. (for instance, if the first qubit is in state |0> and second is in state |1>, their joint state would be visualize as |01>)
Installation
Install from PyPI
pip install QiskitExtension
Install from source
git clone --depth 1 https://github.com/Slope86/QiskitExtension
cd QiskitExtension
pip install .
Configuration
The configuration file is located at ~/qiskit_extension/config/config.ini
; This section sets up the notation for the StateVector(affect the visualization result and the constructor funcition from_label() ).
; The default notation uses |j> to represent |-i>.
; You can change the notation to other character if necessary. (only accept single character.)
[ket]
z0 = 0
z1 = 1
x0 = +
x1 = -
y0 = i
y1 = j
Usage
Examples
Creating an EPR pair with circuit:
from qiskit_extension.quantum_circuit2 import QuantumCircuit2 as qc2
from qiskit_extension.state_vector2 import StateVector2 as sv2
# the circuit for creating EPR pair
circuit_EPR = qc2(2)
circuit_EPR.h(0)
circuit_EPR.cx(0, 1)
# create a ground state
state00 = sv2.from_label('00')
# evolve the state with the circuit
state_EPR = state00.evolve(circuit_EPR)
# visualize the state
state_EPR.show_state() #|00> + |11>
Creating an EPR pair from label:
from qiskit_extension.state_vector2 import StateVector2 as sv2
# create an EPR pair from label
state_EPR = sv2.from_label("00","11")
# visualize the state
state_EPR.show_state() #1/√2(|00> + |11>)
Visualize the state with different basis:
from qiskit_extension.state_vector2 import StateVector2 as sv2
# create an EPR pair from label
state_EPR = sv2.from_label("00","11")
# visualize the state
state_EPR.show_state() #1/√2(|00> + |11>)
state_EPR.show_state(basis='xx') #1/√2(|++> + |-->)
state_EPR.show_state(basis='yy') #1/√2(|ij> + |ji>)
More examples can be found in the examples folder.
Requirement
Python >= 3.10
qiskit[visualization] >= 0.22.3
License
This QiskitExtension project is open source under the MIT license. However, the extensions that are installed separately are not part of the QiskitExtension project. They all have their own licenses!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file QiskitExtension-0.1.3.tar.gz
.
File metadata
- Download URL: QiskitExtension-0.1.3.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e5b74d585a337f713779123426cbff32d596a7adae377706162328a729db09a |
|
MD5 | 5b66c61617f1816620ccde9e1a900064 |
|
BLAKE2b-256 | 2ee5b19ca5e623385fff92ce027c7c4ae4b763743a77d3943b488cba5c9ba8ee |
File details
Details for the file QiskitExtension-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: QiskitExtension-0.1.3-py3-none-any.whl
- Upload date:
- Size: 19.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f57662bc91b83a3f2a7696b8c4ad133cb374aa7d453d3cb806e2ebf407114f60 |
|
MD5 | 47be1c494c79805abe2310ed1b67ac2e |
|
BLAKE2b-256 | ee4428d6dd2c679c045ec75a0800b1bde56fae969ded001a5faa4ce223651a72 |