Thank you for your interest in contributing to PyNumDiff! This document provides guidelines and instructions for contributing to the project.
- How Can I Contribute?
- Development Setup
- Code Style Guidelines
- Testing Guidelines
- Pull Request Process
- Reporting Bugs
- Proposing Features
- Look for issues labeled
good first issueif you're new to the project - Fork the repository
- Create a branch for your changes
- Make your changes following our guidelines
- Submit a pull request
- Python 3.11 or higher
- Git
- (Optional) A virtual environment manager (venv, conda, etc.)
-
Fork the repository on GitHub
-
Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/PyNumDiff.git cd PyNumDiff -
Add the upstream repository:
git remote add upstream https://github.com/florisvb/PyNumDiff.git
-
Create a virtual environment (recommended):
# Using venv python -m venv venv # Activate on Windows venv\Scripts\activate # Activate on macOS/Linux source venv/bin/activate
-
Install the package in development mode:
pip install -e . -
Install development dependencies:
pip install pytest pylint
-
Verify the installation:
pytest -s
pynumdiff/- Main source codeexamples/- Jupyter notebook examplesdocs/- Documentation source files.github/workflows/- GitHub Actions CI configurationtests/- Test files (if applicable)
There's no strict coding style enforced. The main guideline is to match the existing code style in the project. When contributing:
- Match existing method signatures and docstring formats
- Follow the naming conventions used in the existing codebase
- Use 4 spaces for indentation (no tabs)
The project uses pylint for code quality checks. While linting hasn't been strictly enforced recently, it will be important for the planned JOSS (Journal of Open Source Software) submission, which has stricter requirements.
To run linting checks:
-
Run pylint on your changes:
pylint pynumdiff/
-
Or use the project's linting script:
python linting.py
The project includes an .editorconfig file that ensures consistent formatting. Most modern editors support EditorConfig automatically.
PyNumDiff uses pytest for testing. To run tests:
# Run all tests
pytest -s
# Run tests with plots (to visualize method results)
pytest -s --plot
# Run tests with bounds (to print log error bounds)
pytest -s --bounds- Write tests for new features and bug fixes
- Follow the existing test structure
- Ensure all tests pass before submitting a PR
- Tests should be deterministic and not depend on external resources
The test suite is organized into several test files:
test_diff_methods: Broadly tests for correctness and ability to actually differentiatetest_utils: Contains tests of miscellaneous functionality like simulations and evaluation metricstest_optimize: Tests the hyperparameter optimization code
The project uses GitHub Actions for continuous integration. All pull requests are automatically tested. Make sure your changes pass all CI checks before requesting a review.
-
Update your fork with the latest changes from upstream:
git fetch upstream git checkout master git merge upstream/master
-
Create a feature branch:
git checkout -b feature/your-feature-name # or git checkout -b fix/your-bug-fix-name -
Make your changes following the code style guidelines
-
Write or update tests as needed
-
Run tests to ensure everything passes:
pytest -s
-
Run linting to check code quality:
python linting.py
-
Commit your changes with clear, descriptive commit messages (see Commit Messages)
-
Push your branch to your fork:
git push origin feature/your-feature-name
-
Open a Pull Request on GitHub:
- Go to the PyNumDiff repository
- Click "New Pull Request"
- Select your fork and branch
- Fill out the PR template with:
- A clear title and description
- Reference to the related issue (e.g., "Fixes #169")
- Description of changes
- Any breaking changes
-
Wait for CI to run and ensure all checks pass
-
Respond to feedback from maintainers and reviewers
-
Keep your PR up to date by rebasing on master if needed:
git fetch upstream git rebase upstream/master git push --force-with-lease origin feature/your-feature-name
- Smaller, focused PRs are generally easier to review
- Ensure all CI checks pass
- Request review from maintainers when ready
- Be responsive to feedback
- Check existing issues to see if the bug has already been reported
- Test with the latest version to ensure the bug still exists
- Check the documentation to ensure you're using the library correctly
When reporting a bug, please include:
- Clear and descriptive title
- Steps to reproduce:
- What you were trying to do
- What you expected to happen
- What actually happened
- Minimal code example that reproduces the issue
- Environment information:
- Python version
- PyNumDiff version
- Operating system
- Error messages or stack traces (if applicable)
- Additional context (screenshots, data files, etc.)
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. ...
2. ...
**Expected behavior**
A clear and concise description of what you expected to happen.
**Code example**
```python
# Minimal code that reproduces the issueEnvironment
- Python version:
- PyNumDiff version:
- OS:
Additional context Add any other context about the problem here.
## Proposing Features
### Before Proposing a Feature
1. **Check existing issues** to see if the feature has been discussed
2. **Consider the scope** - is it within the project's goals?
3. **Think about implementation** - is it feasible?
### How to Propose a Feature
When proposing a feature, please include:
1. **Clear and descriptive title**
2. **Problem statement**: What problem does this feature solve?
3. **Proposed solution**: How would you implement it?
4. **Alternatives considered**: What other approaches did you consider?
5. **Additional context**: Examples, use cases, etc.
### Feature Request Template
```markdown
**Is your feature request related to a problem?**
A clear and concise description of what the problem is.
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or examples about the feature request here.
We encourage descriptive commit messages that explain what changed and why. Long, detailed commit messages are appreciated as they help others understand the project's history.
feat: A new featurefix: A bug fixdocs: Documentation only changesstyle: Code style changes (formatting, missing semicolons, etc.)refactor: Code refactoring without changing functionality
If you have questions about contributing:
- Check the documentation
- Look through existing issues
- Open a new issue with the
questionlabel
Thank you for contributing to PyNumDiff! 🎉