Contributing
Thank you for your interest in contributing to QPyth! This document provides guidelines and instructions for contributing to the project.
Code of Conduct
Please be respectful and constructive in all interactions. We aim to maintain a welcoming and inclusive community.
Getting Started
Prerequisites
- Python 3.10 or higher
- Git
- GitHub account
Development Setup
- Fork the repository on GitHub
- Clone your fork:
- Create a virtual environment:
- Install in development mode:
- Install pre-commit hooks:
Development Workflow
Branch Strategy
main- Stable production codefeature/*- New featuresbugfix/*- Bug fixesdocs/*- Documentation updates
Creating a Branch
Making Changes
- Make your changes
- Run tests:
pytest - Run linter:
ruff check . - Format code:
ruff format . - Commit changes:
git commit -m "Your commit message"
Commit Messages
Follow conventional commits format:
Types:
- feat - New feature
- fix - Bug fix
- docs - Documentation changes
- style - Code style changes (formatting)
- refactor - Code refactoring
- test - Test changes
- chore - Maintenance tasks
Example:
feat(vqe): add support for LiH molecule
- Add LiH molecule configuration
- Update VQE core to handle multi-electron systems
- Add tests for LiH VQE
Closes #123
Pull Requests
- Push your branch:
- Create a pull request on GitHub
- Fill out the PR template
- Wait for review
Testing
Running Tests
Run all tests:
Run specific test file:
Run with coverage:
Run specific test:
Writing Tests
Follow these guidelines:
- Use descriptive test names
- Test both success and failure cases
- Use fixtures for common setup
- Mock external dependencies
Example:
import pytest
from quantumpytho.modules.bloch_ascii import run_bloch_ascii
def test_run_bloch_ascii_zero_state(capsys):
"""Test Bloch visualization for |0⟩ state."""
run_bloch_ascii(theta=0, phi=0)
captured = capsys.readouterr()
assert "|0> state:" in captured.out
assert "100.00%" in captured.out
Code Style
Formatting
We use Ruff for code formatting:
Linting
Check for issues:
Auto-fix issues:
Style Guidelines
- Use type hints for function signatures
- Write docstrings for all public functions and classes
- Keep functions focused and small
- Use descriptive variable names
- Follow PEP 8 guidelines
Documentation
Docstrings
Use Google-style docstrings:
def run_bloch_ascii(theta: float, phi: float, shots: int = 1024) -> None:
"""Visualize quantum state on Bloch sphere.
Args:
theta: Polar angle in radians [0, π].
phi: Azimuthal angle in radians [0, 2π].
shots: Number of measurement shots.
Returns:
None (prints to stdout)
"""
pass
Documentation Updates
- Update relevant documentation when adding features
- Add examples for new functionality
- Keep API reference up to date
- Update CHANGELOG.md for user-facing changes
Project Structure
QPyth/
├── quantumpytho/ # Main package
│ ├── modules/ # Quantum modules
│ ├── data/ # Calibration data
│ ├── config.py # Configuration
│ ├── engine.py # Core engine
│ └── menu.py # CLI interface
├── tests/ # Test suite
├── docs/ # Documentation
├── web/ # Web UI
├── notebooks/ # Jupyter notebooks
└── pyproject.toml # Project configuration
Adding Features
New Module
- Create module in
quantumpytho/modules/ - Add tests in
tests/ - Update documentation
- Add to CLI menu if applicable
- Add web UI endpoint if applicable
New Molecule
- Add configuration in
quantumpytho/modules/vqe_molecules.py - Add reference energy
- Add tests
- Update documentation
New Noise Profile
- Add calibration CSV to
quantumpytho/data/backends/ - Update noise builder
- Add tests
- Update documentation
Issue Reporting
Bug Reports
Include: - Python version - QPyth version - Steps to reproduce - Expected behavior - Actual behavior - Error messages
Feature Requests
Include: - Use case - Proposed solution - Alternatives considered
Questions
- Use GitHub Discussions for questions
- Check existing issues first
- Be specific and provide context
Release Process
Releases are managed by maintainers:
- Update version in
pyproject.toml - Update CHANGELOG.md
- Create release branch
- Tag release
- Build and publish to PyPI
- Create GitHub release
License
By contributing, you agree that your contributions will be licensed under the Apache License 2.0.
Getting Help
- GitHub Issues: https://github.com/quantumdynamics927-dotcom/QPyth/issues
- GitHub Discussions: https://github.com/quantumdynamics927-dotcom/QPyth/discussions
- Email: quantumdynamics927@gmail.com
Thank you for contributing to QPyth!