Skip to content

Commit d256724

Browse files
committed
Deploying to gh-pages from @ 45b64d2 🚀
1 parent 063d9ef commit d256724

File tree

3 files changed

+69
-9
lines changed

3 files changed

+69
-9
lines changed

_sources/contributing.md.txt

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

contributing.html

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,15 @@ <h1>Contributing<a class="headerlink" href="#contributing" title="Link to this h
266266
have found themselves writing private array-agnostic functions in the process of
267267
converting code to consume the standard.</p>
268268
<p>Thanks to <a class="reference internal" href="contributors.html"><span class="std std-doc">all contributors</span></a> so far!</p>
269-
<section id="how-to-contribute-a-function">
270-
<h2>How to contribute a function<a class="headerlink" href="#how-to-contribute-a-function" title="Link to this heading"></a></h2>
269+
<section id="how-to-contribute-a-new-function">
270+
<h2>How to contribute a new function<a class="headerlink" href="#how-to-contribute-a-new-function" title="Link to this heading"></a></h2>
271271
<ul class="simple">
272272
<li><p><a class="reference external" href="https://github.com/data-apis/array-api-extra/issues/new">Open an issue</a> to
273-
propose the new function.</p></li>
274-
<li><p>Add the implementation of your function to <code class="docutils literal notranslate"><span class="pre">src/array_api_extra/_funcs.py</span></code>.</p>
273+
propose the new function. You may want to wait for initial feedback on the
274+
issue before diving into an implementation. Feel free to skip this step if
275+
there is already an open issue for the function.</p></li>
276+
<li><p>Add the implementation of your function to
277+
<code class="docutils literal notranslate"><span class="pre">src/array_api_extra/_lib/_funcs.py</span></code>.</p>
275278
<ul>
276279
<li><p>Ensure that your function includes type annotations and a
277280
<a class="reference external" href="https://numpydoc.readthedocs.io/en/latest/format.html">numpydoc-style docstring</a>.</p></li>
@@ -285,6 +288,32 @@ <h2>How to contribute a function<a class="headerlink" href="#how-to-contribute-a
285288
<li><p><a class="reference external" href="https://github.com/data-apis/array-api-extra/pulls">Make a PR!</a></p></li>
286289
</ul>
287290
</section>
291+
<section id="how-to-add-delegation-to-a-function">
292+
<h2>How to add delegation to a function<a class="headerlink" href="#how-to-add-delegation-to-a-function" title="Link to this heading"></a></h2>
293+
<p>See <a class="reference external" href="https://github.com/data-apis/array-api-extra/issues/100">the tracker for adding delegation</a>.</p>
294+
<ul class="simple">
295+
<li><p>If you would like to discuss the task before diving into the implementation,
296+
click on the three dots next to the function on the tracker issue, and choose
297+
“Convert to sub-issue”.</p></li>
298+
<li><p>Create a function in <code class="docutils literal notranslate"><span class="pre">src/array_api_extra/_delegation.py</span></code> with a signature
299+
matching the function in <code class="docutils literal notranslate"><span class="pre">src/array_api_extra/_lib/_funcs.py</span></code>, and move the
300+
docstring to the new function. Leave a one-line docstring in <code class="docutils literal notranslate"><span class="pre">_funcs.py</span></code>,
301+
pointing to <code class="docutils literal notranslate"><span class="pre">_delegation.py</span></code> to see the full docstring.</p></li>
302+
<li><p>Also move the initial <code class="docutils literal notranslate"><span class="pre">array_namespace</span></code> call and any input validation over to
303+
the new function.</p></li>
304+
<li><p>Add delegation to backends using the <code class="docutils literal notranslate"><span class="pre">if</span> <span class="pre">_delegate</span></code> pattern. See
305+
<code class="docutils literal notranslate"><span class="pre">src/array_api_extra/_lib/_backends.py</span></code> for the full list of backends we have
306+
worked with so far.</p></li>
307+
<li><p>After all delegation layers, return the result from the implementation in
308+
<code class="docutils literal notranslate"><span class="pre">_funcs</span></code>.</p></li>
309+
<li><p>Simplify the signature in <code class="docutils literal notranslate"><span class="pre">_funcs.py</span></code> to remove impossible arguments now that
310+
it is only called internally via <code class="docutils literal notranslate"><span class="pre">_delegation</span></code>. For example, the <code class="docutils literal notranslate"><span class="pre">xp</span></code>
311+
parameter can be changed from type <code class="docutils literal notranslate"><span class="pre">ModuleType</span> <span class="pre">|</span> <span class="pre">None</span></code> to <code class="docutils literal notranslate"><span class="pre">ModuleType</span></code>.</p></li>
312+
<li><p>Don’t worry if you are not sure how to do some of the above steps or think you
313+
might have done something wrong -
314+
<a class="reference external" href="https://github.com/data-apis/array-api-extra/pulls">make a PR!</a></p></li>
315+
</ul>
316+
</section>
288317
<section id="development-workflow">
289318
<h2>Development workflow<a class="headerlink" href="#development-workflow" title="Link to this heading"></a></h2>
290319
<p>If you are an experienced contributor to Python packages, feel free to develop
@@ -431,7 +460,8 @@ <h2>Development workflow<a class="headerlink" href="#development-workflow" title
431460
<div class="toc-tree">
432461
<ul>
433462
<li><a class="reference internal" href="#">Contributing</a><ul>
434-
<li><a class="reference internal" href="#how-to-contribute-a-function">How to contribute a function</a></li>
463+
<li><a class="reference internal" href="#how-to-contribute-a-new-function">How to contribute a new function</a></li>
464+
<li><a class="reference internal" href="#how-to-add-delegation-to-a-function">How to add delegation to a function</a></li>
435465
<li><a class="reference internal" href="#development-workflow">Development workflow</a></li>
436466
</ul>
437467
</li>

0 commit comments

Comments
 (0)