Thank you for your interest in contributing to Quantum Encoding Atlas! This document provides guidelines and instructions for contributing.
- Getting Started
- Development Setup
- Making Changes
- Adding New Encodings
- Testing
- Documentation
- Pull Request Process
- Code Style
-
Fork the repository on GitHub
-
Clone your fork locally:
git clone https://github.com/<your-username>/quantum-encoding-atlas.git cd quantum-encoding-atlas
-
Add the upstream repository as a remote:
git remote add upstream https://github.com/encoding-atlas/quantum-encoding-atlas.git
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install the package in development mode with all dependencies:
pip install -e ".[dev,docs,all]" -
Install pre-commit hooks:
pre-commit install
-
Verify your setup:
pytest
-
Create a new branch for your changes:
git checkout -b feature/your-feature-name
-
Make your changes, following our code style guidelines
-
Add tests for your changes
-
Run the test suite:
pytest
-
Run linting:
ruff check src tests black --check src tests mypy src
-
Commit your changes:
git add . git commit -m "Add meaningful commit message"
To add a new encoding:
-
Create a new file in
src/encoding_atlas/encodings/(or add to existing file if it's a variant) -
Implement the encoding class inheriting from
BaseEncoding:from encoding_atlas.core.base import BaseEncoding from encoding_atlas.core.properties import EncodingProperties class MyNewEncoding(BaseEncoding): """Description of the encoding. Parameters ---------- n_features : int Number of features to encode. my_param : type Description of parameter. Examples -------- >>> encoding = MyNewEncoding(n_features=4) >>> circuit = encoding.get_circuit(data) """ def __init__(self, n_features: int, my_param: type = default) -> None: super().__init__(n_features, my_param=my_param) self.my_param = my_param @property def n_qubits(self) -> int: # Return number of qubits needed ... @property def depth(self) -> int: # Return circuit depth ... def get_circuit(self, x, backend="pennylane"): # Generate circuit ... def get_circuits(self, X, backend="pennylane"): # Generate circuits for batch ... def _compute_properties(self) -> EncodingProperties: # Return encoding properties ...
-
Register the encoding in
src/encoding_atlas/encodings/_registry.py -
Export it in
src/encoding_atlas/encodings/__init__.py -
Add comprehensive tests in
tests/unit/encodings/test_my_new_encoding.py -
Add documentation in
docs/encodings/my-new-encoding.md
Run the full test suite:
pytestRun with coverage:
pytest --cov=encoding_atlas --cov-report=htmlRun specific tests:
pytest tests/unit/encodings/test_angle.py -vRun tests across Python versions:
nox -s testsBuild documentation locally:
mkdocs serveThen visit http://localhost:8000 to preview.
Documentation style:
- Use Google-style docstrings
- Include examples in docstrings
- Add mathematical notation where appropriate
- Reference original papers
- Update documentation if needed
- Add tests for new functionality
- Ensure all tests pass
- Update CHANGELOG.md
- Create a pull request with a clear description
- Tests pass locally
- Documentation updated
- CHANGELOG.md updated
- Code follows style guidelines
- Commits are clean and well-described
We use:
- Black for code formatting (line length 88)
- Ruff for linting
- mypy for type checking
- Google-style docstrings
Type hints are required for all public functions:
def compute_expressibility(
encoding: BaseEncoding,
n_samples: int = 1000,
seed: int | None = None,
) -> float:
"""Compute expressibility of an encoding.
Parameters
----------
encoding : BaseEncoding
The encoding to analyze.
n_samples : int, default=1000
Number of samples.
seed : int or None, default=None
Random seed.
Returns
-------
float
Expressibility value.
"""
...Feel free to open an issue for any questions about contributing!