You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: contributing.html
+35-5Lines changed: 35 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -266,12 +266,15 @@ <h1>Contributing<a class="headerlink" href="#contributing" title="Link to this h
266
266
have found themselves writing private array-agnostic functions in the process of
267
267
converting code to consume the standard.</p>
268
268
<p>Thanks to <aclass="reference internal" href="contributors.html"><spanclass="std std-doc">all contributors</span></a> so far!</p>
269
-
<sectionid="how-to-contribute-a-function">
270
-
<h2>How to contribute a function<aclass="headerlink" href="#how-to-contribute-a-function" title="Link to this heading">¶</a></h2>
269
+
<sectionid="how-to-contribute-a-new-function">
270
+
<h2>How to contribute a new function<aclass="headerlink" href="#how-to-contribute-a-new-function" title="Link to this heading">¶</a></h2>
271
271
<ulclass="simple">
272
272
<li><p><aclass="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 <codeclass="docutils literal notranslate"><spanclass="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>
@@ -285,6 +288,32 @@ <h2>How to contribute a function<a class="headerlink" href="#how-to-contribute-a
285
288
<li><p><aclass="reference external" href="https://github.com/data-apis/array-api-extra/pulls">Make a PR!</a></p></li>
286
289
</ul>
287
290
</section>
291
+
<sectionid="how-to-add-delegation-to-a-function">
292
+
<h2>How to add delegation to a function<aclass="headerlink" href="#how-to-add-delegation-to-a-function" title="Link to this heading">¶</a></h2>
293
+
<p>See <aclass="reference external" href="https://github.com/data-apis/array-api-extra/issues/100">the tracker for adding delegation</a>.</p>
294
+
<ulclass="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 <codeclass="docutils literal notranslate"><spanclass="pre">src/array_api_extra/_delegation.py</span></code> with a signature
299
+
matching the function in <codeclass="docutils literal notranslate"><spanclass="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 <codeclass="docutils literal notranslate"><spanclass="pre">_funcs.py</span></code>,
301
+
pointing to <codeclass="docutils literal notranslate"><spanclass="pre">_delegation.py</span></code> to see the full docstring.</p></li>
302
+
<li><p>Also move the initial <codeclass="docutils literal notranslate"><spanclass="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 <codeclass="docutils literal notranslate"><spanclass="pre">if</span><spanclass="pre">_delegate</span></code> pattern. See
305
+
<codeclass="docutils literal notranslate"><spanclass="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
<li><p>Simplify the signature in <codeclass="docutils literal notranslate"><spanclass="pre">_funcs.py</span></code> to remove impossible arguments now that
310
+
it is only called internally via <codeclass="docutils literal notranslate"><spanclass="pre">_delegation</span></code>. For example, the <codeclass="docutils literal notranslate"><spanclass="pre">xp</span></code>
311
+
parameter can be changed from type <codeclass="docutils literal notranslate"><spanclass="pre">ModuleType</span><spanclass="pre">|</span><spanclass="pre">None</span></code> to <codeclass="docutils literal notranslate"><spanclass="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
+
<aclass="reference external" href="https://github.com/data-apis/array-api-extra/pulls">make a PR!</a></p></li>
315
+
</ul>
316
+
</section>
288
317
<sectionid="development-workflow">
289
318
<h2>Development workflow<aclass="headerlink" href="#development-workflow" title="Link to this heading">¶</a></h2>
290
319
<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
0 commit comments