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. Please join our weekly community meetings on Discord if you have any questions or need help.
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:
For bash users:
pip install -e .[tests]
For zsh users:
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: We use
rufffor handling code formatting. If you have installed our pre-commit hook, it should be automatically taken care of at each commit. - Naming: Choose clear, descriptive names (avoid single-letter variables). Ideally, the variable name should give you a clear idea of what the variable represents.
- Strings: Use f-strings (
f"{var} = {value}"). - File I/O: Use context managers (
with open(...) as f:). - 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.
- We have beginner friendly issues labelled as "Good First Issue". You can filter by the label on GitHub issues to see the complete list.
- Before starting to work on any issue, please comment on it to get it assigned to you.
- Please try to discuss your design/solution on the issues page before opening a PR.
If you have questions or want to discuss anything related to the project, please join our Discord server (the link is in the README). We also host weekly dev and Community meetings that you can join to ask any questions live or listen to what others are working on.
All contributions—big and small—are welcome. Let’s build a better pgmpy together! Happy coding! 🚀