Thank you for your interest in contributing to GetDist! This guide will help you set up your development environment and understand our coding standards.
- Python 3.10 or higher
- Git
- uv (recommended) or pip for package management
-
Clone the repository:
git clone https://github.com/cmbant/getdist.git cd getdist -
Install in development mode with development dependencies:
Using uv (recommended):
uv pip install -e ".[dev]"Using pip:
pip install -e ".[dev]"This installs GetDist in editable mode along with development tools including:
pre-commitfor code quality checkspytestfor testing
-
Set up pre-commit hooks:
pre-commit install
For specific development tasks, you may need additional dependencies:
- GUI development:
uv pip install -e ".[GUI]"(adds PySide6) - Streamlit GUI:
uv pip install -e ".[StreamlitGUI]"(adds Streamlit) - Documentation:
uv pip install -e ".[docs]"(adds Sphinx and related tools) - All dependencies:
uv pip install -e ".[dev,GUI,StreamlitGUI,docs]"
GetDist uses Ruff for code formatting and linting. The configuration is defined in pyproject.toml:
- Line length: 120 characters
- Quote style: Double quotes
- Target Python version: 3.10+
- Import sorting: Enabled (isort-compatible)
Pre-commit hooks automatically run code quality checks before each commit:
- Ruff linting with auto-fix enabled
- Ruff formatting for consistent code style
The hooks are configured in .pre-commit-config.yaml and will:
- Automatically fix common issues
- Block commits if unfixable issues are found
- Ensure consistent code formatting across the project
You can manually run the code quality checks at any time:
# Run on all files
pre-commit run --all-files
# Run on staged files only
pre-commit run
# Run specific hook
pre-commit run ruff-check
pre-commit run ruff-formatGetDist includes unit tests to ensure code quality and functionality:
# Run all tests
python -m pytest
# Run specific test file
python -m pytest getdist/tests/getdist_test.py
# Run the basic unit test (legacy method)
python -m unittest getdist.tests.getdist_testIf you're using VS Code, the repository includes pre-configured launch configurations and tasks:
Launch Configurations (F5 menu):
Run GetDist Tests- Run tests using unittestDebug GetDist Tests- Debug tests with breakpointsRun GetDist Tests (pytest)- Run tests using pytestDebug GetDist Tests (pytest)- Debug tests with pytest
Tasks (Ctrl+Shift+P → "Tasks: Run Task"):
Run GetDist Tests- Quick test executionRun GetDist Tests (pytest)- Run with pytestRun All Tests- Run all tests in the projectRun Pre-commit- Run code quality checks
Keyboard Shortcuts:
Ctrl+Shift+T- Run GetDist TestsCtrl+Shift+F5- Launch GetDist TestsCtrl+Shift+F6- Debug GetDist TestsCtrl+Shift+P- Run Pre-commit checks
When adding new features or fixing bugs:
- Add appropriate tests in the
getdist/tests/directory - Ensure tests pass locally before submitting
- Aim for good test coverage of new code
-
Create a feature branch:
git checkout -b feature/your-feature-name
-
Make your changes following the code standards above
-
Test your changes:
# Run tests python -m pytest # Run code quality checks pre-commit run --all-files
-
Commit your changes:
git add . git commit -m "Description of your changes"
The pre-commit hooks will run automatically and may modify files or block the commit if issues are found.
-
Push and create a pull request:
git push origin feature/your-feature-name
Use clear, descriptive commit messages:
- Start with a brief summary (50 characters or less)
- Use the imperative mood ("Add feature" not "Added feature")
- Include more details in the body if necessary
- Ensure all tests pass
- Include tests for new functionality
- Update documentation if needed
- Keep changes focused and atomic
- Respond to code review feedback promptly
GetDist has several main components:
- Command line/Python API: Core functionality for sample analysis
- Qt GUI: Desktop application (
getdist/gui/mainwindow.py) using PySide6 - Streamlit GUI: Web-based interface (
getdist/gui/streamlit_app.py) - Plotting library: Publication-ready plotting tools
- Sample analysis: MCMC chain analysis and statistics
- Check the documentation
- Look at existing issues
- Ask questions in new issues with the "question" label