|
1 | 1 | # Contributing to Photoelastimetry |
2 | 2 |
|
3 | | -Thank you for your interest in contributing to photoelastimetry! This document provides guidelines for contributing to the project. |
| 3 | +Canonical contributor documentation lives in the developer docs: |
4 | 4 |
|
5 | | -## Development Setup |
| 5 | +- Setup: `docs/developer/setup.md` |
| 6 | +- Testing: `docs/developer/testing.md` |
| 7 | +- Contributing workflow: `docs/developer/contributing.md` |
| 8 | +- Architecture context: `docs/developer/architecture.md` |
| 9 | +- Docs/release maintenance: `docs/developer/release-and-docs.md` |
6 | 10 |
|
7 | | -1. Fork and clone the repository: |
8 | | -```bash |
9 | | -git clone https://github.com/YOUR_USERNAME/photoelastimetry.git |
10 | | -cd photoelastimetry |
11 | | -``` |
12 | | - |
13 | | -2. Create a virtual environment and install development dependencies: |
14 | | -```bash |
15 | | -python -m venv venv |
16 | | -source venv/bin/activate # On Windows: venv\Scripts\activate |
17 | | -pip install -e ".[dev]" |
18 | | -``` |
19 | | - |
20 | | -## Testing |
21 | | - |
22 | | -### Running Tests |
23 | | - |
24 | | -We use `pytest` for testing. Tests are located in the `tests/` directory and organized by module: |
25 | | - |
26 | | -- `tests/test_stokes_solver_pytest.py` - Tests for Stokes-based stress recovery |
27 | | -- `tests/test_intensity_solver.py` - Tests for intensity-based stress recovery |
28 | | -- `tests/test_equilibrium_solver.py` - Tests for equilibrium-constrained recovery |
29 | | -- `tests/test_disk.py` - Tests for disk simulations |
30 | | -- `tests/test_image_io.py` - Tests for image processing and I/O |
31 | | - |
32 | | -Run all tests: |
33 | | -```bash |
34 | | -pytest |
35 | | -``` |
36 | | - |
37 | | -Run tests with verbose output: |
38 | | -```bash |
39 | | -pytest -v |
40 | | -``` |
41 | | - |
42 | | -Run a specific test file: |
43 | | -```bash |
44 | | -pytest tests/test_stokes_solver_pytest.py |
45 | | -``` |
46 | | - |
47 | | -Run a specific test function: |
48 | | -```bash |
49 | | -pytest tests/test_stokes_solver_pytest.py::TestStokesComponents::test_compute_stokes_components |
50 | | -``` |
51 | | - |
52 | | -### Code Coverage |
53 | | - |
54 | | -We aim for >70% test coverage. Check coverage with: |
55 | | - |
56 | | -```bash |
57 | | -pytest --cov=photoelastimetry --cov-report=html |
58 | | -``` |
59 | | - |
60 | | -View the detailed coverage report: |
61 | | -```bash |
62 | | -open htmlcov/index.html # On macOS |
63 | | -xdg-open htmlcov/index.html # On Linux |
64 | | -start htmlcov/index.html # On Windows |
65 | | -``` |
66 | | - |
67 | | -### Writing Tests |
68 | | - |
69 | | -When adding new features, please include tests: |
| 11 | +## Quick Local Validation |
70 | 12 |
|
71 | | -1. **Unit tests**: Test individual functions in isolation |
72 | | -2. **Integration tests**: Test how components work together |
73 | | -3. **Edge cases**: Test boundary conditions and error handling |
74 | | - |
75 | | -Example test structure: |
76 | | -```python |
77 | | -import pytest |
78 | | -import numpy as np |
79 | | -from photoelastimetry.solver.stokes_solver import function_to_test |
80 | | - |
81 | | -@pytest.fixture |
82 | | -def sample_data(): |
83 | | - """Fixture providing test data.""" |
84 | | - return { |
85 | | - 'param1': value1, |
86 | | - 'param2': value2, |
87 | | - } |
88 | | - |
89 | | -class TestFeature: |
90 | | - """Test class for a specific feature.""" |
91 | | - |
92 | | - def test_basic_functionality(self, sample_data): |
93 | | - """Test basic use case.""" |
94 | | - result = function_to_test(**sample_data) |
95 | | - assert result is not None |
96 | | - assert np.isfinite(result) |
97 | | - |
98 | | - def test_edge_case(self): |
99 | | - """Test edge case or error handling.""" |
100 | | - with pytest.raises(ValueError): |
101 | | - function_to_test(invalid_input) |
102 | | -``` |
103 | | - |
104 | | -## Code Style |
105 | | - |
106 | | -We follow PEP 8 style guidelines with some modifications: |
107 | | - |
108 | | -- Line length: 110 characters (configured in `pyproject.toml`) |
109 | | -- Use `black` for automatic formatting |
110 | | -- Use `flake8` for linting |
111 | | - |
112 | | -Format your code: |
113 | 13 | ```bash |
| 14 | +pip install -e ".[dev,docs]" |
114 | 15 | black photoelastimetry tests |
| 16 | +pytest |
| 17 | +mkdocs build --strict |
115 | 18 | ``` |
116 | 19 |
|
117 | | -Check code style: |
118 | | -```bash |
119 | | -flake8 photoelastimetry --max-line-length=110 |
120 | | -``` |
121 | | - |
122 | | -## Pull Request Process |
123 | | - |
124 | | -1. **Create a feature branch:** |
125 | | - ```bash |
126 | | - git checkout -b feature/your-feature-name |
127 | | - ``` |
128 | | - |
129 | | -2. **Make your changes and add tests:** |
130 | | - - Write clear, documented code |
131 | | - - Add tests for new functionality |
132 | | - - Update documentation if needed |
133 | | - |
134 | | -3. **Ensure all tests pass:** |
135 | | - ```bash |
136 | | - pytest |
137 | | - black photoelastimetry tests |
138 | | - flake8 photoelastimetry |
139 | | - ``` |
140 | | - |
141 | | -4. **Commit your changes:** |
142 | | - ```bash |
143 | | - git add . |
144 | | - git commit -m "Add feature: brief description" |
145 | | - ``` |
146 | | - |
147 | | -5. **Push to your fork and create a pull request:** |
148 | | - ```bash |
149 | | - git push origin feature/your-feature-name |
150 | | - ``` |
151 | | - |
152 | | -6. **In your PR description, include:** |
153 | | - - What changes you made and why |
154 | | - - Any relevant issue numbers (#123) |
155 | | - - Screenshots if applicable |
156 | | - - Confirmation that tests pass |
157 | | - |
158 | | -## Continuous Integration |
159 | | - |
160 | | -Our GitHub Actions workflow automatically: |
161 | | -- Runs tests on Python 3.9, 3.10, 3.11, and 3.12 |
162 | | -- Checks code formatting with `black` |
163 | | -- Runs linting with `flake8` |
164 | | -- Uploads coverage reports to Codecov |
165 | | - |
166 | | -Your PR must pass all CI checks before it can be merged. |
167 | | - |
168 | | -## Documentation |
169 | | - |
170 | | -When adding new features: |
171 | | - |
172 | | -1. **Add docstrings** following NumPy style: |
173 | | - ```python |
174 | | - def my_function(param1, param2): |
175 | | - """ |
176 | | - Brief description of the function. |
177 | | -
|
178 | | - Parameters |
179 | | - ---------- |
180 | | - param1 : type |
181 | | - Description of param1. |
182 | | - param2 : type |
183 | | - Description of param2. |
184 | | -
|
185 | | - Returns |
186 | | - ------- |
187 | | - return_type |
188 | | - Description of return value. |
189 | | -
|
190 | | - Examples |
191 | | - -------- |
192 | | - >>> result = my_function(1, 2) |
193 | | - >>> print(result) |
194 | | - 3 |
195 | | - """ |
196 | | - return param1 + param2 |
197 | | - ``` |
198 | | - |
199 | | -2. **Update docs/** if adding major features |
200 | | -3. **Add examples** to `docs/examples.md` if relevant |
201 | | - |
202 | | -## Questions? |
203 | | - |
204 | | -If you have questions or need help: |
205 | | -- Open an issue on GitHub |
206 | | -- Email the maintainers (see README.md) |
| 20 | +## Pull Requests |
207 | 21 |
|
208 | | -Thank you for contributing! |
| 22 | +- Keep PR scope focused. |
| 23 | +- Include tests for behavior changes. |
| 24 | +- Update docs when interfaces, workflows, or config keys change. |
0 commit comments