Skip to main content

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

中文示範 / English demo

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

MiKTeX (for LaTeX visualization)
Python >= 3.10
qiskit[visualization] == 1.0.0
qiskit-aer == 0.13.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!

Metadata

Release files for QiskitExtension 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for QiskitExtension 0.1.4
File Size Uploaded
QiskitExtension-0.1.4.tar.gz 16.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for QiskitExtension 0.1.4
File Interpreter ABI Platform
QiskitExtension-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 36.3 kB

Release files / QiskitExtension-0.1.4.tar.gz

Download URL QiskitExtension-0.1.4.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ed8f4c1819e61fdf8e1ad9d2016ed10aa23929814f571671315c899804db2327
BLAKE2b-256 checksum
How to use checksums
6eacbb3ce9c91547c415b0ae855133281bd0786603df82ffab15529cb058c1e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.8

Release files / QiskitExtension-0.1.4-py3-none-any.whl

Download URL QiskitExtension-0.1.4-py3-none-any.whl
Size 19.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6f17703c5a835495a5daf67e990095d843ae037b3bf9aadf06fe6ffe3dd43354
BLAKE2b-256 checksum
How to use checksums
308e98e080416b6c56c23bde270d749447d7583403e68c2d88a5096f46e9122c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.8
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page