Welcome and thank you for your interest in making pgmpy even better! This guide walks you through everything you need to know to get started, from setting up your development environment to submitting pull requests and getting feedback.
Before you write any code, please:
- Fork the repository on GitHub: https://github.com/pgmpy/pgmpy
- Clone your fork locally:
git clone git@github.com:<your-username>/pgmpy.git
cd pgmpy
- Create and switch to a feature branch based on
dev:
git checkout dev
git pull origin dev
git checkout -b feature/your-descriptive-name
Install pgmpy (plus testing dependencies) in editable mode:
pip install -e .[tests]
This lets you tweak code and immediately see your changes without re-installing.
We use pytest for testing and GitHub Actions for Continuous Integration (CI).
- To run tests locally:
pytest -v pgmpy
- Tip: Use test-driven development—write your tests first, then implement functionality.
To ensure consistent formatting, we use pre-commit with Black, Flake8, etc.
- Install hooks:
pip install pre-commit
pre-commit install
- On each commit, code will be automatically formatted and linted.
Documentation is built with Sphinx. Please follow the steps in our Maintenance Guide to build docs locally: https://github.com/pgmpy/pgmpy/wiki/Maintenance-Guide#building-docs
Use GitHub issues to report:
- Bugs: include a minimal reproducible example and environment details.
- Questions: describe what you’re trying to achieve and any roadblocks.
- Suggestions: propose new features or enhancements.
Try to fill out the issue template as much as possible so maintainers have all the information they need.
If you plan to add a model, algorithm, or major feature:
- Open an issue first, describing:
- The feature or algorithm you want to add
- Why it’s useful for pgmpy
- A rough implementation plan or API sketch
- Wait for feedback and approval from maintainers. This prevents duplicated effort and ensures alignment with project goals.
We follow a lightweight GitFlow on top of our dev branch:
- Work in your feature branch (e.g., feature/infer-optimization).
- Commit early and often—ensure tests pass before each commit.
- Push your branch to your fork:
git push origin feature/your-descriptive-name
- Open a pull request against the
devbranch via GitHub’s web interface. - Respond to review comments and make any requested changes.
- Formatting: Black is our standard—let pre-commit handle this.
- Naming: Choose clear, descriptive names (avoid single-letter variables).
- Strings: Use f-strings (f"{var} = {value}").
- File I/O: Use context managers (with open(...) as f:).
- Remove dead code: Turn all # TODO comments into GitHub issues.
- Commit messages: Write concise, informative messages (see Thoughtbot’s guide).
Every new function or bug fix must include tests:
- Unit tests for individual methods and edge cases.
- Integration tests if your change spans multiple modules.
- Aim for meaningful coverage rather than 100% lines.
If you have questions or want to brainstorm:
- Discord channel: invite link in the repo’s README.
- Mailing list: check the README for subscription info.
All contributions—big and small—are welcome. Let’s build a better pgmpy together! Happy coding! 🚀