Skip to main content

A Python library for simulating quantum computers and quantum algorithms

Project description

Quantum Simulator

Tests PyPI version Documentation Python versions License: Unlicense

A Python library for simulating quantum computers and quantum algorithms. This package provides an easy-to-use interface for quantum state simulation, gate operations, and circuit execution.

Features

  • 🔬 Quantum State Simulation: Accurate simulation of quantum states using state vectors
  • 🚪 Quantum Gates: Implementation of common single and multi-qubit gates (X, Y, Z, H, CNOT)
  • 🔗 Quantum Circuits: Build and execute complex quantum circuits
  • 📊 Measurement: Simulate quantum measurements with proper state collapse
  • 🎯 Easy to Use: Clean, intuitive API for quantum programming
  • 📚 Well Documented: Comprehensive documentation and examples

Quick Start

Installation

pip install quantum-simulator

Basic Example

from quantum_simulator import QuantumSimulator, QuantumCircuit
from quantum_simulator.gates import H_GATE, CNOT_GATE

# Create a 2-qubit quantum simulator
sim = QuantumSimulator(2)

# Build a Bell state circuit
circuit = QuantumCircuit(2)
circuit.add_gate(H_GATE, [0])        # Hadamard on qubit 0
circuit.add_gate(CNOT_GATE, [0, 1])  # CNOT with control=0, target=1

# Execute the circuit
circuit.execute(sim)

# Measure the qubits
result0 = sim.measure(0)
result1 = sim.measure(1)
print(f"Measurement: {result0}, {result1}")

Documentation

Full documentation is available at beefy.github.io/quantum-simulator

Development

Setting Up Development Environment

  1. Clone the repository:

    git clone https://github.com/beefy/quantum-simulator.git
    cd quantum-simulator
    
  2. Install in development mode:

    pip install -e .[dev,docs]
    
  3. Run tests:

    pytest --cov=quantum_simulator --cov-report=xml --cov-report=term
    
  4. Run lint checks:

    flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
    mypy src/
    
  5. Build documentation:

    mkdocs serve
    

Publishing

Publishing to PyPI

This project uses automated publishing via GitHub Actions. To publish a new version:

1. Prepare the Release

  1. Update version in src/quantum_simulator/__init__.py:

    __version__ = "0.2.0"  # Increment version number
    
  2. Update CHANGELOG.md with release notes

  3. Commit changes:

    git add .
    git commit -m "Bump version to 0.2.0"
    git push
    

2. Create a Release

  1. Create and push a tag:

    git tag v0.2.0
    git push origin v0.2.0
    
  2. Create a GitHub Release:

    • Go to GitHub Releases
    • Click "Create a new release"
    • Choose the tag you just created
    • Add release notes
    • Click "Publish release"
  3. Automated Publishing:

    • GitHub Actions will automatically build and publish to PyPI
    • Check the Actions tab for progress

3. Manual Publishing (if needed)

If automated publishing fails, you can publish manually:

# Install build tools
pip install build twine

# Build the package
python -m build

# Upload to PyPI (requires PyPI API token)
twine upload dist/*

Publishing Documentation

Documentation is automatically deployed to GitHub Pages on every push to the main branch.

Manual Documentation Deployment

# Install documentation dependencies
pip install -e .[docs]

# Build and deploy to GitHub Pages
mkdocs gh-deploy

Local Documentation Development

# Serve documentation locally with auto-reload
mkdocs serve

# Open http://localhost:8000 in your browser

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quantum_simulator-0.1.2.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quantum_simulator-0.1.2-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file quantum_simulator-0.1.2.tar.gz.

File metadata

  • Download URL: quantum_simulator-0.1.2.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for quantum_simulator-0.1.2.tar.gz
Algorithm Hash digest
SHA256 023250585b696e2f35c1ff7abc9f11e708651861f9a0ff1d0506d7c2d9fc8bcf
MD5 394d2bb7b3fb97304ecece7b27140edd
BLAKE2b-256 ddcc56f8920f991943d366275cb8b1b225ea48f0b0fed4a0d9b8a2e5861277a7

See more details on using hashes here.

File details

Details for the file quantum_simulator-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for quantum_simulator-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cda4c8b7ad37b5f005ec9077c181b1b2210e658bafd21177314207210ddcd979
MD5 ba11be1ea6063121c3ca401beb3ab0cf
BLAKE2b-256 1669bce82d5fd45d35bf0ba0cccbdc98fd2475ffe0c86a5fe54ede483bf2d646

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page