Skip to content

Commit 45b64d2

Browse files
authored
Merge pull request #103 from lucascolley/contributor-docs
2 parents 70d3e32 + 49da2ce commit 45b64d2

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

docs/contributing.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ converting code to consume the standard.
66

77
Thanks to [all contributors](contributors.md) so far!
88

9-
## How to contribute a function
9+
## How to contribute a new function
1010

1111
- [Open an issue](https://github.com/data-apis/array-api-extra/issues/new) to
12-
propose the new function.
13-
- Add the implementation of your function to `src/array_api_extra/_funcs.py`.
12+
propose the new function. You may want to wait for initial feedback on the
13+
issue before diving into an implementation. Feel free to skip this step if
14+
there is already an open issue for the function.
15+
- Add the implementation of your function to
16+
`src/array_api_extra/_lib/_funcs.py`.
1417
- Ensure that your function includes type annotations and a
1518
[numpydoc-style docstring](https://numpydoc.readthedocs.io/en/latest/format.html).
1619
- Add your function to `__all__` at the top of the file.
@@ -20,6 +23,33 @@ Thanks to [all contributors](contributors.md) so far!
2023
- Add your function to `docs/api-reference.md`.
2124
- [Make a PR!](https://github.com/data-apis/array-api-extra/pulls)
2225

26+
## How to add delegation to a function
27+
28+
See [the tracker for adding delegation][delegation-tracker].
29+
30+
[delegation-tracker]: https://github.com/data-apis/array-api-extra/issues/100
31+
32+
- If you would like to discuss the task before diving into the implementation,
33+
click on the three dots next to the function on the tracker issue, and choose
34+
"Convert to sub-issue".
35+
- Create a function in `src/array_api_extra/_delegation.py` with a signature
36+
matching the function in `src/array_api_extra/_lib/_funcs.py`, and move the
37+
docstring to the new function. Leave a one-line docstring in `_funcs.py`,
38+
pointing to `_delegation.py` to see the full docstring.
39+
- Also move the initial `array_namespace` call and any input validation over to
40+
the new function.
41+
- Add delegation to backends using the `if _delegate` pattern. See
42+
`src/array_api_extra/_lib/_backends.py` for the full list of backends we have
43+
worked with so far.
44+
- After all delegation layers, return the result from the implementation in
45+
`_funcs`.
46+
- Simplify the signature in `_funcs.py` to remove impossible arguments now that
47+
it is only called internally via `_delegation`. For example, the `xp`
48+
parameter can be changed from type `ModuleType | None` to `ModuleType`.
49+
- Don't worry if you are not sure how to do some of the above steps or think you
50+
might have done something wrong -
51+
[make a PR!](https://github.com/data-apis/array-api-extra/pulls)
52+
2353
## Development workflow
2454

2555
If you are an experienced contributor to Python packages, feel free to develop

0 commit comments

Comments
 (0)