Simple module allowing to record animations to trace changes in qubit states for arbitrary quantum circuits. https://pypi.org/project/qiskit-state-evolution-recorder/
  • Python 99.4%
  • OpenQASM 0.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Release Bot e9238cee84
All checks were successful
release / deploy (push) Successful in 19m37s
Test / test (push) Successful in 34m10s
chore(release): 1.0.6
2026-11-23 06:28:25 +00:00
.forgejo/workflows ci: the test results as a comment on the pull request 2026-11-20 14:23:43 +01:00
.vscode chore: refactor and review dep chains 2026-04-09 13:58:56 +02:00
src/qiskit_state_evolution_recorder chore: refactor and review dep chains 2026-04-09 13:58:56 +02:00
tests chore: refactor and review dep chains 2026-04-09 13:58:56 +02:00
.cz.toml ci: the release bot's Commitizen configuration 2026-11-05 19:30:45 +01:00
.gitignore update dependencies and refactor 2025-06-05 00:00:03 +02:00
CHANGELOG.md chore(release): 1.0.6 2026-11-23 06:28:25 +00:00
LICENSE Initial commit 2024-10-27 14:54:55 +01:00
pyproject.toml fix(deps): update dependency numpy to <2.5.6 2026-11-19 00:24:04 +00:00
README.md docs(readme): replace retired and obsolete badges 2026-11-09 22:47:04 +01:00
renovate.json ci(test): a test workflow on main, renovate/all-patch and pull requests; renovate.json without ignoreTests, so Renovate's patches merge once it passes instead of unchecked 2026-11-09 17:43:15 +01:00

test Release Libraries.io dependency status for GitHub repo


qiskit-state-evolution-recorder

Simple module allowing to record animations to trace changes in qubit states for arbitrary quantum circuits.

Installation

pip install qiskit-state-evolution-recorder

Usage

from qiskit.circuit import QuantumCircuit
from qiskit_state_evolution_recorder import StateEvolutionRecorder

qc = QuantumCircuit(4)
# apply Pauli X-gate
qc.x(3)
# apply Hadamart gate
qc.h(range(4))
# apply Toffoli gate
qc.mcx(list(range(3)), 3)
# apply Hadamart gate
qc.h(range(4))
qc.measure_all()

recorder = StateEvolutionRecorder(qc, figsize=(12, 8), num_cols=4, style={'name': 'bw'})
# evolve the circuit using 120 intermediate states for each qubit
# since we have 5 fundamental states it will lead to 481 frames
recorder.evolve(120)
# with FPS of 30, the video duration will be 16.033333s
recorder.record("quantum_circuit.mp4", fps=30)

In a Jupyter notebook, you can do:

from IPython.display import Video

video = Video("quantum_circuit.mp4")
video.reload()
video

https://github.com/user-attachments/assets/8a3c8567-cbb8-4271-9c2c-9588130c01b0

Testing

Running Tests

The project includes both unit tests and performance tests. Performance tests can be run optionally.

# Run all tests except performance tests
python -m pytest --benchmark-skip

# Run all tests including performance tests
python -m pytest --benchmark-enable

# Run only performance tests
python -m pytest --benchmark-enable --benchmark-only

Backend Support

The library supports multiple animation backends:

  • FFmpeg (default, preferred): Uses matplotlib's FuncAnimation with FFmpeg
  • OpenCV: Uses OpenCV for video creation (fallback when FFmpeg is not available)

The system automatically selects the best available backend. To install additional backends:

# Install OpenCV backend
pip install opencv-python

# Install FFmpeg (system-dependent)
# Ubuntu/Debian: sudo apt-get install ffmpeg
# macOS: brew install ffmpeg
# Windows: Download from https://ffmpeg.org/download.html