Thank you for your interest in contributing to TRIGRS-PyWrap! This document provides guidelines for contributing to the project.
By participating in this project, you are expected to:
- Be respectful and inclusive
- Welcome newcomers and help them get started
- Focus on constructive feedback
- Accept responsibility and learn from mistakes
If you find a bug, please open an issue on GitHub with:
- A clear, descriptive title
- Steps to reproduce the problem
- Expected vs. actual behavior
- Your environment (OS, Python version, dependencies)
- Any relevant error messages or logs
Enhancement suggestions are tracked as GitHub issues. When creating an enhancement suggestion, include:
- A clear description of the proposed feature
- Why this enhancement would be useful
- Possible implementation approach (if you have one)
- Examples of how the feature would be used
We actively welcome pull requests:
- Fork the repository and create your branch from
main - Make your changes following the coding standards below
- Test your changes thoroughly
- Update documentation if you've changed APIs or added features
- Submit a pull request with a clear description of your changes
- Ensure all tests pass and code follows style guidelines
- Update the README.md with details of interface changes if applicable
- Provide a clear description of the problem and solution
- Reference any related issues in your PR description
# Clone your fork
git clone https://github.com/YOUR_USERNAME/trigrs-pywrap.git
cd trigrs-pywrap
# Create virtual environment
python3 -m venv .trigrsenv
source .trigrsenv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Install development dependencies (if applicable)
pip install pytest black flake8 mypy# Run all tests
pytest
# Run specific test file
pytest tests/test_geohazards.py
# Run with coverage
pytest --cov=geohazards --cov-report=html- Follow PEP 8 style guide
- Use meaningful variable and function names
- Keep functions focused and modular
- Maximum line length: 88 characters (Black default)
Use Black for automatic formatting:
black geohazards.pyAdd type hints to function signatures:
def calculate_slope(dem: xr.DataArray, unit: str = "deg") -> xr.DataArray:
"""Calculate slope from DEM."""
passUse Google-style docstrings:
def example_function(param1: str, param2: int) -> bool:
"""
Brief description of function.
Longer description if needed, explaining the function's purpose,
behavior, and any important details.
Args:
param1: Description of param1
param2: Description of param2
Returns:
Description of return value
Raises:
ValueError: When invalid input is provided
Example:
>>> result = example_function("test", 42)
>>> print(result)
True
"""
pass- Write self-documenting code when possible
- Add comments for complex logic or non-obvious decisions
- Keep comments up-to-date with code changes
- Variables/Functions:
snake_case - Classes:
PascalCase - Constants:
UPPER_SNAKE_CASE - Private methods:
_leading_underscore
When adding new features, follow the existing structure:
trigrs-pywrap/
├── geohazards.py # Core functionality
├── Trigrs.py # Example/demonstration scripts
├── tests/ # Unit tests (create if needed)
├── docs/ # Additional documentation
└── examples/ # Usage examples
Write clear, concise commit messages:
Short summary (50 chars or less)
More detailed explanation if needed. Wrap at 72 characters.
Explain what and why, not how.
- Bullet points are okay
- Use present tense ("Add feature" not "Added feature")
- Reference issues: "Fixes #123" or "Related to #456"
- Write tests for all new functionality
- Ensure existing tests still pass
- Aim for high code coverage (>80%)
- Test edge cases and error conditions
import pytest
from geohazards import TRIGRS
def test_slope_calculation():
"""Test slope calculation from DEM."""
# Arrange
dem = create_test_dem()
# Act
slope = calculate_slope(dem)
# Assert
assert slope.min() >= 0
assert slope.max() <= 90When adding features, update the README with:
- Usage examples
- New dependencies
- Configuration options
- Breaking changes
Provide working examples for new features:
- Include sample data or data generation code
- Show complete, runnable examples
- Explain the purpose and expected output
- Correctness: Does the code work as intended?
- Tests: Are there adequate tests?
- Documentation: Is it well-documented?
- Style: Does it follow project conventions?
- Simplicity: Is it the simplest solution?
- Initial review within 1 week
- Follow-up responses within 3-5 days
- We appreciate your patience!
- Open an issue for questions
- Tag issues with appropriate labels
- Be patient and respectful when awaiting responses
We especially welcome contributions in:
- Cross-platform support: Testing and fixes for Mac/Linux
- Documentation: Examples, tutorials, API documentation
- Testing: Unit tests, integration tests, test data
- Performance: Optimization of computational routines
- Features: New analysis capabilities, output formats
- Bug fixes: Addressing known issues
Contributors will be:
- Listed in the project contributors
- Mentioned in release notes for significant contributions
- Appreciated for their effort and time!
Don't hesitate to ask! Open an issue with the "question" label, and we'll be happy to help.
By contributing, you agree that your contributions will be licensed under the same license as the project.
Thank you for contributing to TRIGRS-PyWrap! 🎉