Not a coder? Not a problem! NumPy is multi-faceted, and we can use a lot of help. These are all activities we’d like to get help with (they’re all important, so we list them in alphabetical order):
We understand that everyone has a different level of experience, also NumPy is a pretty well-established project, so it’s hard to make assumptions about an ideal “first-time-contributor”. So, that’s why we don’t mark issues with the “good-first-issue” label. Instead, you’ll find issues labeled “Sprintable”. These issues can either be:
Additionally, depending on your prior experience, some “Sprintable” issues might be easy, while others could be more challenging for you.
The rest of this document discusses working on the NumPy code base and documentation. We’re in the process of updating our descriptions of other activities and roles. If you are interested in these other activities, please contact us! You can do this via the numpy-discussion mailing list, or on GitHub (open an issue or comment on a relevant issue). These are our preferred communication channels (open source is open by nature!), however if you prefer to discuss in a more private space first, you can do so on Slack (see numpy.org/contribute for details).
Here’s the short summary, complete TOC links are below:
If you are a first-time contributor:
Clone the project to your local computer:
git clone --recurse-submodules https://github.com/your-username/numpy.git
Change the directory:
cd numpy
Add the upstream repository:
git remote add upstream https://github.com/numpy/numpy.git
Now, git remote -v will show two remote repositories named:
upstream, which refers to the numpy repositoryorigin, which refers to your personal forkPull the latest changes from upstream, including tags:
git checkout main git pull upstream main --tags
Initialize numpy’s submodules:
git submodule update --init
Develop your contribution:
Create a branch for the feature you want to work on. Since the branch name will appear in the merge message, use a sensible name such as ‘linspace-speedups’:
git checkout -b linspace-speedups
git add and git commit) Use a properly formatted commit message, write tests that fail before your change and pass afterward, run all the tests locally. Be sure to document any changed behavior in docstrings, keeping to the NumPy docstring standard.To submit your contribution:
Push your changes back to your fork on GitHub:
git push origin linspace-speedups
Review process:
Document changes
Beyond changes to a functions docstring and possible description in the general documentation, if your change introduces any user-facing modifications they may need to be mentioned in the release notes. To add your change to the release notes, you need to create a short file with a summary and place it in doc/release/upcoming_changes. The file doc/release/upcoming_changes/README.rst details the format and filename conventions.
If your change introduces a deprecation, make sure to discuss this first on GitHub or the mailing list first. If agreement on the deprecation is reached, follow NEP 23 deprecation policy to add the deprecation.
Cross referencing issues
If the PR relates to any issues, you can add the text xref gh-xxxx where xxxx is the number of the issue to github comments. Likewise, if the PR solves an issue, replace the xref with closes, fixes or any of the other flavors github accepts.
In the source code, be sure to preface any issue or PR reference with gh-xxxx.
For a more detailed discussion, read on and follow the links at the bottom of this page.
Pull requests (PRs) that modify code should either have new tests, or modify existing tests to fail before the PR and pass afterwards. You should run the tests before pushing a PR.
Running NumPy’s test suite locally requires some additional packages, such as pytest and hypothesis. The additional testing dependencies are listed in requirements/test_requirements.txt in the top-level directory, and can conveniently be installed with:
$ python -m pip install -r requirements/test_requirements.txt
Tests for a module should ideally cover all code in that module, i.e., statement coverage should be at 100%.
To measure the test coverage, run:
$ spin test --coverage
This will create a report in html format at build/coverage, which can be viewed with your browser, e.g.:
$ firefox build/coverage/index.html
To build the HTML documentation, use:
spin docs
You can also run make from the doc directory. make help lists all targets.
To get the appropriate dependencies and other requirements, see Building the NumPy API and reference docs.
The rest of the story
NumPy-specific workflow is in numpy-development-workflow.
© 2005–2024 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/2.4/dev/index.html