-
Notifications
You must be signed in to change notification settings - Fork 0
Contributing Guide
milad edited this page May 10, 2026
·
1 revision
Thank you for your interest in contributing to the SIR Epidemic Simulator!
- Code of Conduct
- Getting Started
- Development Setup
- Code Guidelines
- Testing Guidelines
- Documentation Guidelines
- Pull Request Process
- Reporting Issues
- Feature Requests
This project follows the Contributor Covenant Code of Conduct.
By participating, you agree to uphold this code.
| Tool | Version | Check Command |
|---|---|---|
| Python | 3.8+ | python --version |
| Git | Latest | git --version |
| pip | Latest | pip --version |
- Fork the repository on GitHub
- Clone your fork:
git clone https://github.com/YOUR_USERNAME/sir_simulator.git
cd sir_simulator- Add upstream remote:
git remote add upstream https://github.com/miladrezanezhad/sir_simulator.git# Windows
python -m venv venv
venv\Scripts\activate
# Linux/Mac
python3 -m venv venv
source venv/bin/activate# Install package in development mode
pip install -e .
# Install development dependencies
pip install -r requirements_dev.txtpre-commit install# Run all tests
python run_all_tests.py
# Run security tests
python -m unittest discover tests/security
# Check code style
black --check .
flake8 .We follow PEP 8 with some modifications:
| Tool | Configuration |
|---|---|
| Black | Line length: 88 |
| isort | Profile: black |
| flake8 | Max line length: 88, ignore: E203, W503 |
| mypy | Type checking enabled |
# Auto-format code
black .
isort .
# Check formatting without changing
black --check .
isort --check-only .Always include type hints:
# Good
def run_simulation(beta: float, gamma: float, days: int) -> pd.DataFrame:
pass
# Bad
def run_simulation(beta, gamma, days):
passUse Google-style docstrings:
def function_name(param1: str, param2: int) -> bool:
"""
Brief description of function.
Args:
param1: Description of param1
param2: Description of param2
Returns:
Description of return value
Raises:
ValueError: When param1 is invalid
Examples:
>>> function_name("test", 42)
True
"""
pass| Type | Convention | Example |
|---|---|---|
| Variables | snake_case | infected_count |
| Functions | snake_case | run_simulation() |
| Classes | PascalCase | SocialNetworkSimulator |
| Constants | UPPER_SNAKE | MAX_POPULATION |
| Private | _leading_underscore | _internal_method() |
# 1. Standard library
import json
import os
from typing import List
# 2. Third-party
import numpy as np
import pandas as pd
# 3. Local
from sir_simulator.core_models.sir_model import run_sir_simulation- β All new features
- β Bug fixes
- β Refactoring
- β Documentation changes
- β Configuration changes
def test_something():
# Arrange - Set up test data
input_data = create_test_data()
# Act - Execute the code
result = function_to_test(input_data)
# Assert - Verify the result
self.assertEqual(result, expected)# Good - describes behavior
def test_run_sir_returns_dataframe():
pass
def test_calculate_peak_infected_correctly():
pass
# Bad - vague
def test_sir():
pass
def test_function():
pass# Run all tests
python run_all_tests.py
# Run specific test file
python tests/test_seir.py
# Run security tests
python -m unittest discover tests/security
# Run with coverage
coverage run --source=src/sir_simulator -m unittest discover tests
coverage report
coverage htmlAdd to existing file or create new one:
import unittest
from sir_simulator.your_module import your_function
class TestYourFeature(unittest.TestCase):
def test_normal_case(self):
result = your_function(valid_input)
self.assertEqual(result, expected)
def test_edge_case(self):
result = your_function(empty_input)
self.assertEqual(result, expected)
def test_error_case(self):
with self.assertRaises(ValueError):
your_function(invalid_input)
if __name__ == '__main__':
unittest.main()| Change Type | Update |
|---|---|
| New feature | README.md, tutorials, API reference |
| Bug fix | CHANGELOG.md |
| API change | API reference, docstrings |
| Configuration | README.md |
- Brief description
- Args section (type and description)
- Returns section (type and description)
- Raises section (if applicable)
- Examples section (if useful)
When adding features, update relevant sections:
- Installation
- Quick Start
- Usage Guide
- Project Structure
- Update your fork:
git checkout main
git pull upstream main
git push origin main- Create a branch:
git checkout -b feature/your-feature-name- Make changes and commit:
git add .
git commit -m "feat: add your feature description"- Run tests:
python run_all_tests.py
python -m unittest discover tests/security- Push and create PR:
git push origin feature/your-feature-name<type>(<scope>): <subject>
<body>
<footer>
Types:
-
feat: New feature -
fix: Bug fix -
docs: Documentation -
style: Formatting -
refactor: Code refactor -
test: Tests -
chore: Maintenance
Examples:
feat(network): add small-world network generator
fix(optimization): handle edge case when beta is zero
docs(readme): update installation instructions
test(seir): add population conservation testFill out the PR template completely:
- Description of changes
- Type of change
- Testing performed
- Checklist completed
- CI checks must pass
- At least one review required
- Address feedback with additional commits
- Squash commits when approved
- Merge (maintainer will do)
## Bug Description
[Clear description]
## Steps to Reproduce
1. Run command...
2. Enter parameters...
3. See error
## Expected Behavior
[What should happen]
## Actual Behavior
[What actually happens]
## Environment
- OS: [Windows/Linux/Mac]
- Python Version: [e.g., 3.10]
- Package Version: [e.g., 1.0.0]
## Additional Context
[Screenshots, logs, etc.]| Label | Meaning |
|---|---|
bug |
Verified bug |
enhancement |
Feature request |
documentation |
Docs issue |
good-first-issue |
Beginner friendly |
help-wanted |
Need assistance |
question |
Support request |
## Problem Statement
[What problem does this solve?]
## Proposed Solution
[How should it work?]
## Alternative Solutions
[Other approaches considered]
## Use Case
[Who would benefit?]
## Additional Context
[References, examples, etc.]- Code follows style guidelines
- Type hints included
- Docstrings added
- Tests written and passing
- No new warnings
- CHANGELOG updated
- README updated (if needed)
- Tutorials updated (if needed)
- API reference updated (if needed)
- Examples work correctly
- No hardcoded secrets
- Input validation added
- Security tests pass
- No new vulnerabilities
Look for issues labeled good-first-issue:
- Small, self-contained changes
- Clear requirements
- Mentorship available
- Comment on the issue: "I'd like to work on this"
- Follow the PR process
- Ask questions if stuck
| Channel | Use for |
|---|---|
| Issue comments | Specific issue discussion |
| GitHub Discussions | General questions |
| Security or private matters |
All contributors will be added to the CONTRIBUTORS.md file (coming soon).
Significant contributions will be mentioned in the CHANGELOG and README.
Thank you for contributing! π