Contributing
Contributions to COASTSim are welcome! This guide will help you get started.
Development Setup
Fork the repository on GitHub
Clone your fork locally:
git clone https://github.com/YOUR-USERNAME/coast-sim.git cd coast-sim
Install in development mode with dev dependencies:
pip install -e ".[dev]"
Set up pre-commit hooks:
pre-commit install
Code Quality Standards
This project uses several tools to maintain code quality:
Ruff
For linting and code formatting:
ruff check conops/
ruff format conops/
Mypy
For static type checking:
mypy conops/
Pytest
For running tests:
# Run all tests
pytest tests/
# Run with coverage
pytest --cov=conops tests/
# Run specific test file
pytest tests/test_battery.py
Pre-commit
Pre-commit hooks automatically run before each commit:
Code formatting with ruff
Linting checks
Type checking with mypy
Trailing whitespace removal
YAML/JSON validation
Making Changes
Create a feature branch:
git checkout -b feature/your-feature-name
Make your changes
Add tests for new functionality
Ensure all tests pass:
pytest tests/Check code quality:
ruff check conops/ mypy conops/
Commit your changes:
git add . git commit -m "Description of your changes"
Push to your fork:
git push origin feature/your-feature-name
Open a Pull Request on GitHub
Testing Guidelines
Write tests for all new functionality
Maintain or improve code coverage
Use descriptive test names
Include docstrings explaining what each test validates
Use fixtures from
tests/conftest.pywhen appropriate
Example test structure:
def test_battery_discharge():
"""Test that battery discharges correctly over time."""
battery = Battery(capacity=100.0, initial_charge=100.0)
battery.discharge(10.0, duration=3600) # 10W for 1 hour
expected_charge = 100.0 - (10.0 * 3600 / 3600)
assert abs(battery.current_charge - expected_charge) < 1e-6
Documentation
Add docstrings to all public functions, classes, and modules
Use Google or NumPy style docstrings
Include examples in docstrings when helpful
Update documentation when changing functionality
Build docs locally to verify:
cd docs make html open _build/html/index.html
Docstring Example
def compute_slew_time(angle: float, max_rate: float) -> float:
"""Compute the time required to slew a given angle.
Args:
angle: Slew angle in degrees.
max_rate: Maximum slew rate in degrees per second.
Returns:
Time required for the slew in seconds.
Example:
>>> compute_slew_time(90.0, 1.0)
90.0
"""
return angle / max_rate
Pull Request Guidelines
When submitting a pull request:
Provide a clear description of the changes
Reference any related issues
Ensure all tests pass
Maintain or improve code coverage
Follow the existing code style
Update documentation as needed
Keep changes focused and atomic
Reporting Issues
When reporting issues:
Use a clear, descriptive title
Describe the expected behavior
Describe the actual behavior
Provide steps to reproduce
Include version information
Add relevant code snippets or error messages
Feature Requests
Feature requests are welcome! Please:
Check if the feature already exists or is planned
Clearly describe the use case
Explain why it would be valuable
Provide examples if possible
Code of Conduct
Be respectful and inclusive
Welcome newcomers and help them get started
Focus on constructive feedback
Assume good intentions
Getting Help
If you need help:
Check the documentation
Look through existing issues
Open a new issue with your question
Be specific about what you’re trying to accomplish
License
By contributing to COASTSim, you agree that your contributions will be licensed under the same license as the project.
Thank You!
Thank you for contributing to COASTSim! Your contributions help make this project better for everyone.