|
| 1 | +# Contributing |
| 2 | + |
| 3 | +Contributions are welcome from any "array-consuming" library contributors who |
| 4 | +have found themselves writing private array-agnostic functions in the process of |
| 5 | +converting code to consume the standard! |
| 6 | + |
| 7 | +## How to contribute a function |
| 8 | + |
| 9 | +- Add the implementation of your function to `src/array_api_extra/_funcs.py`. |
| 10 | + - Ensure that your function includes type annotations and a |
| 11 | + [numpydoc-style docstring](https://numpydoc.readthedocs.io/en/latest/format.html). |
| 12 | + - Add your function to `__all__` at the top of the file. |
| 13 | +- Import your function to `src/array_api_extra/__init__.py` and add it to |
| 14 | + `__all__` there. |
| 15 | +- Add a test class for your function in `tests/test_funcs.py`. |
| 16 | +- [Make a PR!](https://github.com/data-apis/array-api-extra/pulls) |
| 17 | + |
| 18 | +## Development workflow |
| 19 | + |
| 20 | +If you are an experienced contributor to Python packages, feel free to develop |
| 21 | +however you feel comfortable! However, if you would like some guidance, |
| 22 | +development of array-api-extra is made easy with |
| 23 | +[Pixi](https://pixi.sh/latest/): |
| 24 | + |
| 25 | +- [Clone the repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository) |
| 26 | + at <https://github.com/data-apis/array-api-extra>. |
| 27 | +- `cd array-api-extra`. |
| 28 | +- [Install Pixi](https://pixi.sh/latest/#installation). |
| 29 | +- To enter a development environment: |
| 30 | + |
| 31 | +``` |
| 32 | +pixi shell -e dev |
| 33 | +``` |
| 34 | + |
| 35 | +- To run the tests: |
| 36 | + |
| 37 | +``` |
| 38 | +pixi run test |
| 39 | +``` |
| 40 | + |
| 41 | +- To build the docs locally: |
| 42 | + |
| 43 | +``` |
| 44 | +pixi run docs |
| 45 | +``` |
| 46 | + |
| 47 | +- To install a [pre-commit](https://pre-commit.com) hook and run the lint suite: |
| 48 | + |
| 49 | +``` |
| 50 | +pixi run lint |
| 51 | +``` |
| 52 | + |
| 53 | +- To enter an interactive Python prompt: |
| 54 | + |
| 55 | +``` |
| 56 | +pixi run ipython |
| 57 | +``` |
| 58 | + |
| 59 | +- To run individual parts of the lint suite separately: |
| 60 | + |
| 61 | +``` |
| 62 | +pixi run pre-commit |
| 63 | +pixi run pylint |
| 64 | +pixi run mypy |
| 65 | +``` |
| 66 | + |
| 67 | +Alternative environments are available with a subset of the dependencies and |
| 68 | +tasks available in the `dev` environment: |
| 69 | + |
| 70 | +``` |
| 71 | +pixi shell -e docs |
| 72 | +pixi shell -e test |
| 73 | +pixi shell -e lint |
| 74 | +``` |
0 commit comments