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
    
  4. Build documentation:

    mkdocs serve
    

Project Structure

quantum-simulator/
├── src/quantum_simulator/          # Main package
│   ├── __init__.py                # Package initialization
│   ├── simulator.py               # Quantum simulator implementation
│   ├── gates.py                   # Quantum gates
│   └── circuits.py                # Quantum circuits
├── docs/                          # Documentation source
├── tests/                         # Test suite
├── .github/workflows/             # CI/CD workflows
├── pyproject.toml                 # Package configuration
├── mkdocs.yml                     # Documentation configuration
└── README.md                      # This file

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

Setting Up Automated Publishing

To enable automated publishing for your own fork:

1. PyPI API Token

  1. Create PyPI account at pypi.org
  2. Generate API token at pypi.org/manage/account/token/
  3. Add token to GitHub Secrets:
    • Go to repository Settings → Secrets and variables → Actions
    • Add secret: PYPI_API_TOKEN with your API token value

2. GitHub Pages

  1. Enable GitHub Pages:

    • Go to repository Settings → Pages
    • Source: "GitHub Actions"
  2. Documentation will be available at: https://yourusername.github.io/quantum-simulator/

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Workflow

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make changes and add tests
  4. Run tests: pytest
  5. Submit a pull request

Code Quality

We use several tools to maintain code quality:

  • pytest: Testing framework
  • black: Code formatting
  • flake8: Linting
  • mypy: Type checking
  • pre-commit: Git hooks

Requirements

  • Python: 3.8 or higher
  • NumPy: 1.20.0 or higher

License

This project is licensed under the MIT License - see the LICENSE file for details.

Links

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.0.tar.gz (13.6 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.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for quantum_simulator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 639fabce406dc8429f6a5f1fc23ad85b8462a914bee574fd1f9b988c02dd5d25
MD5 bd9da7c68087ae78b5ba37b0a4dc02f8
BLAKE2b-256 9d276ea7a6ea053331f9670e79127ffdfcdf60a6834bdb162812df998dd90600

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for quantum_simulator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 64de441d1f0481526895c9d5ad848b91bb729c88c6959c8fb9dc770cc6429804
MD5 cc4375c549b49c18359cc4e891710b2b
BLAKE2b-256 0989ad872f9212aebcb9876e16a325174aba3513276b3fca8d7d78f0be873b01

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