Thank you for your interest in contributing to StatPhys-ML! This document provides guidelines and instructions for contributing.
- Code of Conduct
- Getting Started
- Development Setup
- Making Changes
- Code Style
- Testing
- Submitting Changes
Please read and follow our Code of Conduct.
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/statphys-ml.git cd statphys-ml - Add the upstream repository:
git remote add upstream https://github.com/yuma-ichikawa/statphys-ml.git
-
Create a virtual environment:
python -m venv .venv source .venv/bin/activate # Linux/macOS # or .venv\Scripts\activate # Windows
-
Install development dependencies:
pip install -e ".[dev]" -
(Optional) Install pre-commit hooks:
pip install pre-commit pre-commit install
-
Create a new branch for your changes:
git checkout -b feature/your-feature-name # or git checkout -b fix/your-bug-fix -
Make your changes, following the code style guidelines
-
Write or update tests as needed
-
Run tests to ensure everything works:
pytest tests/
-
Commit your changes with a clear message:
git commit -m "Add feature: description of your changes"
We use the following tools to maintain code quality:
- Black for code formatting (line length: 100)
- Ruff for linting
- isort for import sorting
- mypy for type checking
# Format code
black src/ tests/
isort src/ tests/
# Check linting
ruff check src/ tests/
# Type checking
mypy src/- Use type hints for all function signatures
- Write docstrings for all public functions and classes (Google style)
- Keep functions focused and small
- Use meaningful variable names
Example:
def compute_generalization_error(
m: float,
q: float,
rho: float,
) -> float:
"""Compute the generalization error from order parameters.
Args:
m: Student-teacher overlap.
q: Student self-overlap.
rho: Teacher weight norm.
Returns:
The generalization error E_g = rho + q - 2m.
"""
return rho + q - 2 * m# Run all tests
pytest tests/
# Run with coverage
pytest tests/ --cov=statphys --cov-report=html
# Run specific test file
pytest tests/test_dataset.py
# Run tests matching a pattern
pytest tests/ -k "replica"- Place tests in the
tests/directory - Name test files as
test_<module>.py - Use descriptive test names:
test_<what>_<condition> - Use fixtures from
conftest.pyfor common setup
-
Push your branch to your fork:
git push origin feature/your-feature-name
-
Open a Pull Request on GitHub
-
Fill out the PR template with:
- Description of changes
- Related issues (if any)
- Test plan
-
Wait for CI checks to pass
-
Address any review feedback
- Keep PRs focused on a single change
- Update documentation if needed
- Add tests for new features
- Update CHANGELOG.md for user-facing changes
- Use the bug report issue template
- Include steps to reproduce
- Include expected vs actual behavior
- Include environment details
- Use the feature request issue template
- Describe the use case
- Explain why it would be useful
- Fix typos or unclear explanations
- Add examples
- Improve docstrings
- Bug fixes
- New features
- Performance improvements
- Test coverage improvements
Feel free to open an issue for any questions about contributing.
Thank you for contributing to StatPhys-ML!