Skip to content

Commit 47886d9

Browse files
author
array-api-bot
committed
Deploy: 25200b6
1 parent 80602ed commit 47886d9

File tree

5 files changed

+66
-78
lines changed

5 files changed

+66
-78
lines changed

draft/API_specification/generated/array_api.unique_all.html

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -475,38 +475,35 @@ <h1 id="api-specification-generated-array-api-unique-all--page-root">unique_all<
475475
<dd><p>Returns the unique elements of an input array <code class="docutils literal notranslate"><span class="pre">x</span></code>, the first occurring indices for each unique element in <code class="docutils literal notranslate"><span class="pre">x</span></code>, the indices from the set of unique elements that reconstruct <code class="docutils literal notranslate"><span class="pre">x</span></code>, and the corresponding counts for each unique element in <code class="docutils literal notranslate"><span class="pre">x</span></code>.</p>
476476
<div class="important admonition">
477477
<p class="admonition-title">Data-dependent output shape</p>
478-
<p>The shapes of two of the output arrays for this function depend on the data values in the input array; hence, array libraries which build computation graphs (e.g., JAX, Dask, etc.) may find this function difficult to implement without knowing array values. Accordingly, such libraries may choose to omit this function. See <a class="reference internal" href="../../design_topics/data_dependent_output_shapes.html#data-dependent-output-shapes"><span class="std std-ref">Data-dependent output shapes</span></a> section for more details.</p>
478+
<p>The shapes of two of the output arrays for this function depend on the data values in the input array; hence, array libraries which build computation graphs (e.g., JAX, Dask, et cetera) can find this function difficult to implement without knowing array values. Accordingly, such libraries <strong>may</strong> choose to omit this function. See <a class="reference internal" href="../../design_topics/data_dependent_output_shapes.html#data-dependent-output-shapes"><span class="std std-ref">Data-dependent output shapes</span></a> section for more details.</p>
479479
</div>
480-
<div class="admonition note">
481-
<p class="admonition-title">Note</p>
482-
<p>Uniqueness should be determined based on value equality (see <a class="reference internal" href="array_api.equal.html#array_api.equal" title="array_api.equal"><code class="xref py py-func docutils literal notranslate"><span class="pre">equal()</span></code></a>). For input arrays having floating-point data types, value-based equality implies the following behavior.</p>
483-
<ul class="simple">
484-
<li><p>As <code class="docutils literal notranslate"><span class="pre">nan</span></code> values compare as <code class="docutils literal notranslate"><span class="pre">False</span></code>, <code class="docutils literal notranslate"><span class="pre">nan</span></code> values should be considered distinct.</p></li>
485-
<li><p>As complex floating-point values having at least one <code class="docutils literal notranslate"><span class="pre">nan</span></code> component compare as <code class="docutils literal notranslate"><span class="pre">False</span></code>, complex floating-point values having <code class="docutils literal notranslate"><span class="pre">nan</span></code> components should be considered distinct.</p></li>
486-
<li><p>As <code class="docutils literal notranslate"><span class="pre">-0</span></code> and <code class="docutils literal notranslate"><span class="pre">+0</span></code> compare as <code class="docutils literal notranslate"><span class="pre">True</span></code>, signed zeros should not be considered distinct, and the corresponding unique element will be implementation-dependent (e.g., an implementation could choose to return <code class="docutils literal notranslate"><span class="pre">-0</span></code> if <code class="docutils literal notranslate"><span class="pre">-0</span></code> occurs before <code class="docutils literal notranslate"><span class="pre">+0</span></code>).</p></li>
487-
</ul>
488-
<p>As signed zeros are not distinct, using <code class="docutils literal notranslate"><span class="pre">inverse_indices</span></code> to reconstruct the input array is not guaranteed to return an array having the exact same values.</p>
489-
<p>Each <code class="docutils literal notranslate"><span class="pre">nan</span></code> value and each complex floating-point value having a <code class="docutils literal notranslate"><span class="pre">nan</span></code> component should have a count of one, while the counts for signed zeros should be aggregated as a single count.</p>
490-
</div>
491-
<dl class="field-list">
480+
<dl class="field-list simple">
492481
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
493-
<dd class="field-odd"><p><strong>x</strong> (<em>array</em>) – input array. If <code class="docutils literal notranslate"><span class="pre">x</span></code> has more than one dimension, the function must flatten <code class="docutils literal notranslate"><span class="pre">x</span></code> and return the unique elements of the flattened array.</p>
482+
<dd class="field-odd"><p><strong>x</strong> (<em>array</em>) – input array. If <code class="docutils literal notranslate"><span class="pre">x</span></code> has more than one dimension, the function <strong>must</strong> flatten <code class="docutils literal notranslate"><span class="pre">x</span></code> and return the unique elements of the flattened array.</p>
494483
</dd>
495484
<dt class="field-even">Returns<span class="colon">:</span></dt>
496485
<dd class="field-even"><p><strong>out</strong> (<em>Tuple[array, array, array, array]</em>) – a namedtuple <code class="docutils literal notranslate"><span class="pre">(values,</span> <span class="pre">indices,</span> <span class="pre">inverse_indices,</span> <span class="pre">counts)</span></code> whose</p>
497486
<ul class="simple">
498-
<li><p>first element must have the field name <code class="docutils literal notranslate"><span class="pre">values</span></code> and must be a one-dimensional array containing the unique elements of <code class="docutils literal notranslate"><span class="pre">x</span></code>. The array must have the same data type as <code class="docutils literal notranslate"><span class="pre">x</span></code>.</p></li>
499-
<li><p>second element must have the field name <code class="docutils literal notranslate"><span class="pre">indices</span></code> and must be an array containing the indices (first occurrences) of a flattened <code class="docutils literal notranslate"><span class="pre">x</span></code> that result in <code class="docutils literal notranslate"><span class="pre">values</span></code>. The array must have the same shape as <code class="docutils literal notranslate"><span class="pre">values</span></code> and must have the default array index data type.</p></li>
500-
<li><p>third element must have the field name <code class="docutils literal notranslate"><span class="pre">inverse_indices</span></code> and must be an array containing the indices of <code class="docutils literal notranslate"><span class="pre">values</span></code> that reconstruct <code class="docutils literal notranslate"><span class="pre">x</span></code>. The array must have the same shape as <code class="docutils literal notranslate"><span class="pre">x</span></code> and must have the default array index data type.</p></li>
501-
<li><p>fourth element must have the field name <code class="docutils literal notranslate"><span class="pre">counts</span></code> and must be an array containing the number of times each unique element occurs in <code class="docutils literal notranslate"><span class="pre">x</span></code>. The order of the returned counts must match the order of <code class="docutils literal notranslate"><span class="pre">values</span></code>, such that a specific element in <code class="docutils literal notranslate"><span class="pre">counts</span></code> corresponds to the respective unique element in <code class="docutils literal notranslate"><span class="pre">values</span></code>. The returned array must have same shape as <code class="docutils literal notranslate"><span class="pre">values</span></code> and must have the default array index data type.</p></li>
487+
<li><p>first element <strong>must</strong> have the field name <code class="docutils literal notranslate"><span class="pre">values</span></code> and <strong>must</strong> be a one-dimensional array containing the unique elements of <code class="docutils literal notranslate"><span class="pre">x</span></code>. The array <strong>must</strong> have the same data type as <code class="docutils literal notranslate"><span class="pre">x</span></code>.</p></li>
488+
<li><p>second element <strong>must</strong> have the field name <code class="docutils literal notranslate"><span class="pre">indices</span></code> and <strong>must</strong> be an array containing the indices (first occurrences) of a flattened <code class="docutils literal notranslate"><span class="pre">x</span></code> that result in <code class="docutils literal notranslate"><span class="pre">values</span></code>. The array <strong>must</strong> have the same shape as <code class="docutils literal notranslate"><span class="pre">values</span></code> and <strong>must</strong> have the default array index data type.</p></li>
489+
<li><p>third element <strong>must</strong> have the field name <code class="docutils literal notranslate"><span class="pre">inverse_indices</span></code> and <strong>must</strong> be an array containing the indices of <code class="docutils literal notranslate"><span class="pre">values</span></code> that reconstruct <code class="docutils literal notranslate"><span class="pre">x</span></code>. The array <strong>must</strong> have the same shape as <code class="docutils literal notranslate"><span class="pre">x</span></code> and <strong>must</strong> have the default array index data type.</p></li>
490+
<li><p>fourth element <strong>must</strong> have the field name <code class="docutils literal notranslate"><span class="pre">counts</span></code> and <strong>must</strong> be an array containing the number of times each unique element occurs in <code class="docutils literal notranslate"><span class="pre">x</span></code>. The order of the returned counts <strong>must</strong> match the order of <code class="docutils literal notranslate"><span class="pre">values</span></code>, such that a specific element in <code class="docutils literal notranslate"><span class="pre">counts</span></code> corresponds to the respective unique element in <code class="docutils literal notranslate"><span class="pre">values</span></code>. The returned array <strong>must</strong> have same shape as <code class="docutils literal notranslate"><span class="pre">values</span></code> and <strong>must</strong> have the default array index data type.</p></li>
502491
</ul>
503-
<div class="admonition note">
504-
<p class="admonition-title">Note</p>
505-
<p>The order of unique elements is not specified and may vary between implementations.</p>
506-
</div>
507492
</dd>
508493
</dl>
509494
<p class="rubric">Notes</p>
495+
<ul>
496+
<li><p>The order of unique elements returned by this function is unspecified and thus implementation-defined. As a consequence, element order <strong>may</strong> vary between implementations.</p></li>
497+
<li><p>Uniqueness <strong>should</strong> be determined based on value equality (see <a class="reference internal" href="array_api.equal.html#array_api.equal" title="array_api.equal"><code class="xref py py-func docutils literal notranslate"><span class="pre">equal()</span></code></a>). For input arrays having floating-point data types, value-based equality implies the following behavior.</p>
498+
<ul class="simple">
499+
<li><p>As <code class="docutils literal notranslate"><span class="pre">nan</span></code> values compare as <code class="docutils literal notranslate"><span class="pre">False</span></code>, <code class="docutils literal notranslate"><span class="pre">nan</span></code> values <strong>should</strong> be considered distinct.</p></li>
500+
<li><p>As complex floating-point values having at least one <code class="docutils literal notranslate"><span class="pre">nan</span></code> component compare as <code class="docutils literal notranslate"><span class="pre">False</span></code>, complex floating-point values having <code class="docutils literal notranslate"><span class="pre">nan</span></code> components <strong>should</strong> be considered distinct.</p></li>
501+
<li><p>As <code class="docutils literal notranslate"><span class="pre">-0</span></code> and <code class="docutils literal notranslate"><span class="pre">+0</span></code> compare as <code class="docutils literal notranslate"><span class="pre">True</span></code>, signed zeros <strong>should not</strong> be considered distinct, and the corresponding unique element <strong>may</strong> be implementation-defined (e.g., an implementation <strong>may</strong> choose to return <code class="docutils literal notranslate"><span class="pre">-0</span></code> if <code class="docutils literal notranslate"><span class="pre">-0</span></code> occurs before <code class="docutils literal notranslate"><span class="pre">+0</span></code>).</p></li>
502+
</ul>
503+
<p>As signed zeros are not distinct, using <code class="docutils literal notranslate"><span class="pre">inverse_indices</span></code> to reconstruct the input array is not guaranteed to return an array having the exact same values.</p>
504+
<p>Each <code class="docutils literal notranslate"><span class="pre">nan</span></code> value and each complex floating-point value having a <code class="docutils literal notranslate"><span class="pre">nan</span></code> component <strong>should</strong> have a count of one, while the counts for signed zeros <strong>should</strong> be aggregated as a single count.</p>
505+
</li>
506+
</ul>
510507
<div class="versionchanged">
511508
<p><span class="versionmodified changed">Changed in version 2022.12: </span>Added complex data type support.</p>
512509
</div>

0 commit comments

Comments
 (0)