@@ -6,11 +6,14 @@ converting code to consume the standard.
6
6
7
7
Thanks to [ all contributors] ( contributors.md ) so far!
8
8
9
- ## How to contribute a function
9
+ ## How to contribute a new function
10
10
11
11
- [ 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 ` .
14
17
- Ensure that your function includes type annotations and a
15
18
[ numpydoc-style docstring] ( https://numpydoc.readthedocs.io/en/latest/format.html ) .
16
19
- Add your function to ` __all__ ` at the top of the file.
@@ -20,6 +23,33 @@ Thanks to [all contributors](contributors.md) so far!
20
23
- Add your function to ` docs/api-reference.md ` .
21
24
- [ Make a PR!] ( https://github.com/data-apis/array-api-extra/pulls )
22
25
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
+
23
53
## Development workflow
24
54
25
55
If you are an experienced contributor to Python packages, feel free to develop
0 commit comments