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: MIT

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.1.tar.gz (13.3 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.1-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: quantum_simulator-0.1.1.tar.gz
  • Upload date:
  • Size: 13.3 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.1.tar.gz
Algorithm Hash digest
SHA256 8431623d535fb28641b5fdc97328ef9beabc996edb653d9f3a0357cb29889d7b
MD5 3182c3a29a33c75d4a8f5b082c5059c2
BLAKE2b-256 0d38fa878eab3a82f10b6e0794e00a4927e82c55236eb772653274f7e241e92e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for quantum_simulator-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0558884dcb0848bc782218f4d928fd4c48215cc3488ca8e1919d440549060a66
MD5 5b276f31bf44136429db10943ea6213b
BLAKE2b-256 1f065c32cb9be5b7c90154874bd8d96ae5eed7e0c61899aea7e9f11a9f532056

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