|
| 1 | +# Contributing |
| 2 | + |
| 3 | +Contributions are welcome, and they are greatly appreciated! Every little bit |
| 4 | +helps, and credit will always be given. |
| 5 | + |
| 6 | +You can contribute in many ways: |
| 7 | + |
| 8 | +## Types of Contributions |
| 9 | + |
| 10 | +### Report Bugs |
| 11 | + |
| 12 | +Report bugs at https://github.com/Priesemann-Group/mrestimator/issues. |
| 13 | + |
| 14 | +If you are reporting a bug, please include ideally a minimal reproducible example with: |
| 15 | +- Your operating system name and version |
| 16 | +- Python version and mrestimator version |
| 17 | +- Any details about your local setup that might be helpful in troubleshooting |
| 18 | +- Detailed steps to reproduce the bug |
| 19 | + |
| 20 | +### Fix Bugs |
| 21 | + |
| 22 | +Look through the GitHub issues for bugs. Anything tagged with "bug" and |
| 23 | +"help wanted" is open to whoever wants to implement it. |
| 24 | + |
| 25 | +### Implement Features |
| 26 | + |
| 27 | +Look through the GitHub issues for features. Anything tagged with |
| 28 | +"enhancement" and "help wanted" is open to whoever wants to implement |
| 29 | +it. |
| 30 | + |
| 31 | +### Write Documentation |
| 32 | + |
| 33 | +Mr. Estimator could always use more documentation, |
| 34 | +whether as part of the official docs, |
| 35 | +in docstrings, or even on the web in blog posts, articles, and such. |
| 36 | + |
| 37 | +If you're interested in improving documentation, you can: |
| 38 | +- Fix typos and improve clarity in existing documentation |
| 39 | +- Add examples and tutorials |
| 40 | +- Improve docstrings in the code |
| 41 | +- Create blog posts or tutorials about using mrestimator |
| 42 | + |
| 43 | +### Submit Feedback |
| 44 | + |
| 45 | +The best way to send feedback is to file an issue at |
| 46 | +https://github.com/Priesemann-Group/mrestimator/issues. |
| 47 | + |
| 48 | +If you are proposing a feature: |
| 49 | + |
| 50 | +- Explain in detail how it would work. |
| 51 | +- Keep the scope as narrow as possible, to make it easier to |
| 52 | + implement. |
| 53 | +- Remember that this is a volunteer-driven project, and that |
| 54 | + contributions are welcome :) |
| 55 | + |
| 56 | +## Get Started! |
| 57 | + |
| 58 | +Ready to contribute? Here's how to set up `mrestimator` for local development. |
| 59 | + |
| 60 | +1. Fork the `mrestimator` repo on GitHub. |
| 61 | + |
| 62 | +2. Clone your fork locally: |
| 63 | + |
| 64 | +```bash |
| 65 | +git clone [email protected]:your_name_here/mrestimator.git |
| 66 | +``` |
| 67 | + |
| 68 | +3. Create a virtual environment with your favorite tool. We recommend using conda: |
| 69 | + |
| 70 | +```bash |
| 71 | +conda create --name mrestimator-dev python=3.11 |
| 72 | +conda activate mrestimator-dev |
| 73 | +``` |
| 74 | + |
| 75 | +Or with venv: |
| 76 | + |
| 77 | +```bash |
| 78 | +python -m venv mrestimator-dev |
| 79 | +source mrestimator-dev/bin/activate # On Windows: mrestimator-dev\Scripts\activate |
| 80 | +``` |
| 81 | + |
| 82 | +4. Install the package including dev dependencies in editable mode: |
| 83 | + |
| 84 | +```bash |
| 85 | +cd mrestimator/ |
| 86 | +pip install -e ".[dev]" |
| 87 | +``` |
| 88 | + |
| 89 | +This will install: |
| 90 | +- The mrestimator package in development mode |
| 91 | +- All runtime dependencies (numpy, scipy, matplotlib) |
| 92 | +- Optional dependencies (numba, tqdm) |
| 93 | +- Development tools (pre-commit, ruff, testing tools) |
| 94 | +- Documentation dependencies (sphinx, sphinx-book-theme, etc.) |
| 95 | + |
| 96 | +5. Install pre-commit hooks: |
| 97 | + |
| 98 | +```bash |
| 99 | +pre-commit install |
| 100 | +``` |
| 101 | + |
| 102 | +6. Create a branch for local development: |
| 103 | + |
| 104 | +```bash |
| 105 | +git checkout -b name-of-your-bugfix-or-feature |
| 106 | +``` |
| 107 | + |
| 108 | +Now you can make your changes locally. |
| 109 | + |
| 110 | +7. When you're done making changes, check that your code passes the linter and formatter, |
| 111 | + the tests pass, and the documentation builds correctly: |
| 112 | + |
| 113 | +```bash |
| 114 | +# Run linting and formatting |
| 115 | +make lint |
| 116 | +make format |
| 117 | + |
| 118 | +# Run tests |
| 119 | +make test |
| 120 | + |
| 121 | +# Build documentation |
| 122 | +make docs-build |
| 123 | + |
| 124 | +# Or preview documentation locally |
| 125 | +make docs-preview |
| 126 | +``` |
| 127 | + |
| 128 | +Look inside the `Makefile` for more commands. For instance: |
| 129 | +- `make clean` - Remove build artifacts |
| 130 | +- `make check` - Run both linting and tests |
| 131 | +- `make all` - Run the full development cycle |
| 132 | + |
| 133 | +8. Commit your changes and push your branch to GitHub: |
| 134 | + |
| 135 | +```bash |
| 136 | +git add . |
| 137 | +git commit -m "Your detailed description of your changes." |
| 138 | +git push origin name-of-your-bugfix-or-feature |
| 139 | +``` |
| 140 | + |
| 141 | +Please write clear, descriptive commit messages that explain what changes you made and why. |
| 142 | + |
| 143 | +9. Submit a pull request through the GitHub website. |
| 144 | + |
| 145 | +## Pull Request Guidelines |
| 146 | + |
| 147 | +Before you submit a pull request, check that it meets these guidelines: |
| 148 | + |
| 149 | +1. The pull request should include tests for any new functionality. |
| 150 | +2. If the pull request adds functionality, the docs should be updated. |
| 151 | + Put your new functionality into a function with a docstring. |
| 152 | +3. The pull request should work for Python 3.10, 3.11, and 3.12. |
| 153 | +4. Make sure all existing tests still pass. |
| 154 | + |
| 155 | +## Coding Standards |
| 156 | + |
| 157 | +### Code Style |
| 158 | + |
| 159 | +We use `ruff` for code formatting and linting. The configuration is in `pyproject.toml`. |
| 160 | +Run `make format` to automatically format your code and `make lint` to check for issues. |
| 161 | + |
| 162 | +### Documentation Style |
| 163 | + |
| 164 | +- Use NumPy-style docstrings for functions and classes |
| 165 | +- Include examples in docstrings where helpful |
| 166 | +- Keep line length to 88 characters (enforced by ruff) |
| 167 | + |
| 168 | +### Testing |
| 169 | + |
| 170 | +- Write tests for new functionality |
| 171 | +- Use pytest for testing |
| 172 | +- Place tests in the `tests/` directory |
| 173 | +- Test file names should start with `test_` |
| 174 | + |
| 175 | +## Development Environment |
| 176 | + |
| 177 | +### Dependencies |
| 178 | + |
| 179 | +The development environment includes: |
| 180 | + |
| 181 | +**Core dependencies:** |
| 182 | +- numpy (>=1.11) |
| 183 | +- scipy (>=1.0.0) |
| 184 | +- matplotlib (>=1.7.0) |
| 185 | + |
| 186 | +**Optional runtime dependencies:** |
| 187 | +- numba (>=0.44) - for performance improvements |
| 188 | +- tqdm - for progress bars |
| 189 | + |
| 190 | +**Development tools:** |
| 191 | +- pre-commit - for git hooks |
| 192 | +- ruff - for linting and formatting |
| 193 | +- pytest - for testing |
| 194 | + |
| 195 | +**Documentation tools:** |
| 196 | +- sphinx - documentation generator |
| 197 | +- sphinx-book-theme - modern documentation theme |
| 198 | +- myst-parser - Markdown support in docs |
| 199 | +- nbsphinx - Jupyter notebook support |
| 200 | + |
| 201 | +### Performance Considerations |
| 202 | + |
| 203 | +When running on clusters or in distributed environments, you may need to control |
| 204 | +thread usage. Set these environment variables: |
| 205 | + |
| 206 | +```bash |
| 207 | +export OPENBLAS_NUM_THREADS=1 |
| 208 | +export MKL_NUM_THREADS=1 |
| 209 | +export NUMEXPR_NUM_THREADS=1 |
| 210 | +export OMP_NUM_THREADS=1 |
| 211 | +export NUMBA_NUM_THREADS=1 |
| 212 | +``` |
| 213 | + |
| 214 | +## Questions? |
| 215 | + |
| 216 | +If you have questions about contributing, feel free to: |
| 217 | +- Open an issue on GitHub |
| 218 | +- Contact the maintainers directly |
| 219 | +- Join discussions in existing issues |
| 220 | + |
| 221 | +Thank you for contributing to Mr. Estimator! |
0 commit comments