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
<spanclass="sig-name descname"><spanclass="pre">take</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">x</span></span><spanclass="p"><spanclass="pre">:</span></span><spanclass="w"></span><spanclass="n"><spanclass="pre">array</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">indices</span></span><spanclass="p"><spanclass="pre">:</span></span><spanclass="w"></span><spanclass="n"><spanclass="pre">array</span></span></em>, <emclass="sig-param"><spanclass="o"><spanclass="pre">/</span></span></em>, <emclass="sig-param"><spanclass="o"><spanclass="pre">*</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">axis</span></span><spanclass="p"><spanclass="pre">:</span></span><spanclass="w"></span><spanclass="n"><spanclass="pre">int</span><spanclass="w"></span><spanclass="p"><spanclass="pre">|</span></span><spanclass="w"></span><spanclass="pre">None</span></span><spanclass="w"></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="w"></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><spanclass="sig-return"><spanclass="sig-return-icon">→</span><spanclass="sig-return-typehint"><spanclass="pre">array</span></span></span><aclass="headerlink" href="#array_api.take" title="Link to this definition">¶</a></dt>
468
468
<dd><p>Returns elements of an array along an axis.</p>
469
-
<divclass="admonition note">
470
-
<pclass="admonition-title">Note</p>
471
-
<p>Conceptually, <codeclass="docutils literal notranslate"><spanclass="pre">take(x,</span><spanclass="pre">indices,</span><spanclass="pre">axis=3)</span></code> is equivalent to <codeclass="docutils literal notranslate"><spanclass="pre">x[:,:,:,indices,...]</span></code>; however, explicit indexing via arrays of indices is not currently supported in this specification due to concerns regarding <codeclass="docutils literal notranslate"><spanclass="pre">__setitem__</span></code> and array mutation semantics.</p>
<li><p><strong>x</strong> (<em>array</em>) – input array. Should have one or more dimensions (axes).</p></li>
477
-
<li><p><strong>indices</strong> (<em>array</em>) – <p>array indices. The array must be one-dimensional and have an integer data type.</p>
478
-
<divclass="admonition note">
479
-
<pclass="admonition-title">Note</p>
480
-
<p>This specification does not require bounds checking. The behavior for out-of-bounds indices is left unspecified.</p>
481
-
</div>
482
-
</p></li>
483
-
<li><p><strong>axis</strong> (<em>Optional</em><em>[</em><em>int</em><em>]</em>) – <p>axis over which to select values. If <codeclass="docutils literal notranslate"><spanclass="pre">axis</span></code> is negative, the function must determine the axis along which to select values by counting from the last dimension.</p>
473
+
<li><p><strong>indices</strong> (<em>array</em>) – array indices. The array must be one-dimensional and have an integer data type. If an index is negative, the function must determine the element to select along a specified axis (dimension) by counting from the last element (where <codeclass="docutils literal notranslate"><spanclass="pre">-1</span></code> refers to the last element).</p></li>
474
+
<li><p><strong>axis</strong> (<em>Optional</em><em>[</em><em>int</em><em>]</em>) – <p>axis over which to select values. If <codeclass="docutils literal notranslate"><spanclass="pre">axis</span></code> is negative, the function must determine the axis along which to select values by counting from the last dimension (where <codeclass="docutils literal notranslate"><spanclass="pre">-1</span></code> refers to the last dimension).</p>
484
475
<p>If <codeclass="docutils literal notranslate"><spanclass="pre">x</span></code> is a one-dimensional array, providing an <codeclass="docutils literal notranslate"><spanclass="pre">axis</span></code> is optional; however, if <codeclass="docutils literal notranslate"><spanclass="pre">x</span></code> has more than one dimension, providing an <codeclass="docutils literal notranslate"><spanclass="pre">axis</span></code> is required.</p>
<li><p>Conceptually, <codeclass="docutils literal notranslate"><spanclass="pre">take(x,</span><spanclass="pre">indices,</span><spanclass="pre">axis=3)</span></code> is equivalent to <codeclass="docutils literal notranslate"><spanclass="pre">x[:,:,:,indices,...]</span></code>; however, explicit indexing via arrays of indices is not currently supported in this specification due to concerns regarding <codeclass="docutils literal notranslate"><spanclass="pre">__setitem__</span></code> and array mutation semantics.</p></li>
486
+
<li><p>This specification does not require bounds checking. The behavior for out-of-bounds indices is left unspecified.</p></li>
494
487
<li><p>When <codeclass="docutils literal notranslate"><spanclass="pre">x</span></code> is a zero-dimensional array, behavior is unspecified and thus implementation-defined.</p></li>
<li><p><strong>x</strong> (<em>array</em>) – input array. Must be compatible with <codeclass="docutils literal notranslate"><spanclass="pre">indices</span></code>, except for the axis (dimension) specified by <codeclass="docutils literal notranslate"><spanclass="pre">axis</span></code> (see <aclass="reference internal" href="../broadcasting.html#broadcasting"><spanclass="std std-ref">Broadcasting</span></a>).</p></li>
473
-
<li><p><strong>indices</strong> (<em>array</em>) – <p>array indices. Must have the same rank (i.e., number of dimensions) as <codeclass="docutils literal notranslate"><spanclass="pre">x</span></code>.</p>
474
-
<divclass="admonition note">
475
-
<pclass="admonition-title">Note</p>
476
-
<p>This specification does not require bounds checking. The behavior for out-of-bounds indices is left unspecified.</p>
477
-
</div>
478
-
</p></li>
479
-
<li><p><strong>axis</strong> (<em>int</em>) – axis along which to select values. If <codeclass="docutils literal notranslate"><spanclass="pre">axis</span></code> is negative, the function must determine the axis along which to select values by counting from the last dimension. Default: <codeclass="docutils literal notranslate"><spanclass="pre">-1</span></code>.</p></li>
473
+
<li><p><strong>indices</strong> (<em>array</em>) – array indices. Must have the same rank (i.e., number of dimensions) as <codeclass="docutils literal notranslate"><spanclass="pre">x</span></code>. If an index is negative, the function must determine the element to select along a specified axis (dimension) by counting from the last element (where <codeclass="docutils literal notranslate"><spanclass="pre">-1</span></code> refers to the last element).</p></li>
474
+
<li><p><strong>axis</strong> (<em>int</em>) – axis along which to select values. If <codeclass="docutils literal notranslate"><spanclass="pre">axis</span></code> is negative, the function must determine the axis along which to select values by counting from the last dimension (where <codeclass="docutils literal notranslate"><spanclass="pre">-1</span></code> refers to the last dimension). Default: <codeclass="docutils literal notranslate"><spanclass="pre">-1</span></code>.</p></li>
<ddclass="field-even"><p><strong>out</strong> (<em>array</em>) – an array having the same data type as <codeclass="docutils literal notranslate"><spanclass="pre">x</span></code>. Must have the same rank (i.e., number of dimensions) as <codeclass="docutils literal notranslate"><spanclass="pre">x</span></code> and must have a shape determined according to <aclass="reference internal" href="../broadcasting.html#broadcasting"><spanclass="std std-ref">Broadcasting</span></a>, except for the axis (dimension) specified by <codeclass="docutils literal notranslate"><spanclass="pre">axis</span></code> whose size must equal the size of the corresponding axis (dimension) in <codeclass="docutils literal notranslate"><spanclass="pre">indices</span></code>.</p>
484
479
</dd>
485
480
</dl>
481
+
<pclass="rubric">Notes</p>
482
+
<ulclass="simple">
483
+
<li><p>This specification does not require bounds checking. The behavior for out-of-bounds indices is left unspecified.</p></li>
0 commit comments