Contributing
March 10, 2026 · View on GitHub
Thank you for your interest in contributing to TorchOptics!
We welcome contributions from the community to help improve the project.
Reporting bugs, asking questions, or suggesting features
If you encounter a bug, have a question, or would like to suggest a new feature, please open an issue on GitHub with a clear description.
Including screenshots, minimal code examples, or error logs is appreciated.
Development setup
To prepare your environment for development and testing:
- Fork the repository on GitHub.
- Clone your fork:
git clone https://github.com/your-username/torchoptics.git cd torchoptics - Install TorchOptics in development mode:
uv sync --all-extras - Install pre-commit hooks:
pre-commit install
Pre-commit hooks will automatically run the following tools:
- ruff — for code formatting and linting
- pyright — for static type checking
Submitting a pull request
Submit your changes by opening a pull request from your fork.
- Create a new branch:
git checkout -b feature/your-feature-name - Make your changes and commit them.
- Run the tests:
pytest - Push your branch:
git push origin feature/your-feature-name - Open a pull request against the
mainbranch.
Include a clear description and reference any related issues if applicable.
Editing the documentation
If you want to update the documentation, you can preview it locally before submitting a pull request.
-
Build the documentation:
make -C docs html -
Serve the documentation locally:
python -m http.server 8000 --directory docs/build/html
Then open http://localhost:8000/ in your browser. Re-run the build command whenever you change the docs, and refresh the page to see the updates.