Skip to content

Commit b9e04ce

Browse files
author
array-api-bot
committed
Deploy: c7476ba
1 parent 12bc99e commit b9e04ce

File tree

3 files changed

+36
-13
lines changed

3 files changed

+36
-13
lines changed

draft/API_specification/type_promotion.html

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -721,15 +721,26 @@ <h3 id="notes">Notes<a class="headerlink" href="#notes" title="Link to this head
721721
</ul>
722722
<p>Provided the above requirements are met, the expected behavior is equivalent to:</p>
723723
<ol class="arabic simple">
724-
<li><p>Convert the scalar to zero-dimensional array with the same data type as that of the array used in the expression.</p></li>
724+
<li><p>Convert the scalar to a zero-dimensional array with the same data type as that of the array used in the expression.</p></li>
725725
<li><p>Execute the operation for <code class="docutils literal notranslate"><span class="pre">array</span> <span class="pre">&lt;op&gt;</span> <span class="pre">0-D</span> <span class="pre">array</span></code> (or <code class="docutils literal notranslate"><span class="pre">0-D</span> <span class="pre">array</span> <span class="pre">&lt;op&gt;</span> <span class="pre">array</span></code> if <code class="docutils literal notranslate"><span class="pre">scalar</span></code> was the left-hand argument).</p></li>
726726
</ol>
727-
<div class="admonition note">
728-
<p class="admonition-title">Note</p>
727+
<p>Additionally, using Python <code class="docutils literal notranslate"><span class="pre">complex</span></code> scalars together with arrays must be supported for:</p>
728+
<ul class="simple">
729+
<li><p><code class="docutils literal notranslate"><span class="pre">array</span> <span class="pre">&lt;op&gt;</span> <span class="pre">scalar</span></code></p></li>
730+
<li><p><code class="docutils literal notranslate"><span class="pre">scalar</span> <span class="pre">&lt;op&gt;</span> <span class="pre">array</span></code></p></li>
731+
</ul>
732+
<p>where <code class="docutils literal notranslate"><span class="pre">&lt;op&gt;</span></code> is a built-in operator (including in-place operators, but excluding the matmul <code class="docutils literal notranslate"><span class="pre">@</span></code> operator; see <a class="reference internal" href="array_object.html#operators"><span class="std std-ref">Operators</span></a> for operators supported by the array object) and <code class="docutils literal notranslate"><span class="pre">scalar</span></code> has a type and value compatible with a promoted array data type:</p>
733+
<ul class="simple">
734+
<li><p>a Python <code class="docutils literal notranslate"><span class="pre">complex</span></code> for real-valued floating-point array data types.</p></li>
735+
</ul>
736+
<p>Provided the above requirements are met, the expected behavior is equivalent to:</p>
737+
<ol class="arabic simple">
738+
<li><p>Convert the scalar to a zero-dimensional array with a complex floating-point array data type having the same precision as that of the array operand used in the expression (e.g., if an array has a <code class="docutils literal notranslate"><span class="pre">float32</span></code> data type, the scalar must be converted to a zero-dimensional array having a <code class="docutils literal notranslate"><span class="pre">complex64</span></code> data type; if an array has a <code class="docutils literal notranslate"><span class="pre">float64</span></code> data type, the scalar must be converted to a zero-dimensional array have a <code class="docutils literal notranslate"><span class="pre">complex128</span></code> data type).</p></li>
739+
<li><p>Execute the operation for <code class="docutils literal notranslate"><span class="pre">array</span> <span class="pre">&lt;op&gt;</span> <span class="pre">0-D</span> <span class="pre">array</span></code> (or <code class="docutils literal notranslate"><span class="pre">0-D</span> <span class="pre">array</span> <span class="pre">&lt;op&gt;</span> <span class="pre">array</span></code> if <code class="docutils literal notranslate"><span class="pre">scalar</span></code> was the left-hand argument).</p></li>
740+
</ol>
741+
<p>Behavior is not specified for integers outside of the bounds of a given integer data type. Integers outside of bounds may result in overflow or an error.</p>
729742
<p>Behavior is not specified when mixing a Python <code class="docutils literal notranslate"><span class="pre">float</span></code> and an array with an integer data type; this may give <code class="docutils literal notranslate"><span class="pre">float32</span></code>, <code class="docutils literal notranslate"><span class="pre">float64</span></code>, or raise an exception. Behavior is implementation-specific.</p>
730-
<p>Similarly, behavior is not specified when mixing a Python <code class="docutils literal notranslate"><span class="pre">complex</span></code> and an array with a real-valued data type; this may give <code class="docutils literal notranslate"><span class="pre">complex64</span></code>, <code class="docutils literal notranslate"><span class="pre">complex128</span></code>, or raise an exception. Behavior is implementation-specific.</p>
731-
<p>Behavior is also not specified for integers outside of the bounds of a given integer data type. Integers outside of bounds may result in overflow or an error.</p>
732-
</div>
743+
<p>Behavior is not specified when mixing a Python <code class="docutils literal notranslate"><span class="pre">complex</span></code> and an array with an integer data type; this may give <code class="docutils literal notranslate"><span class="pre">complex64</span></code>, <code class="docutils literal notranslate"><span class="pre">complex128</span></code>, or raise an exception. Behavior is implementation-specific.</p>
733744
</section>
734745
</section>
735746
</section>

draft/_sources/API_specification/type_promotion.rst.txt

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ where
110110
- **c16**: double-precision complex floating-point number (i.e., ``complex128``)
111111
composed of two double-precision (64-bit) floating-point numbers
112112

113-
114113
Notes
115114
~~~~~
116115

@@ -140,12 +139,25 @@ where ``<op>`` is a built-in operator (including in-place operators, but excludi
140139

141140
Provided the above requirements are met, the expected behavior is equivalent to:
142141

143-
1. Convert the scalar to zero-dimensional array with the same data type as that of the array used in the expression.
142+
1. Convert the scalar to a zero-dimensional array with the same data type as that of the array used in the expression.
144143
2. Execute the operation for ``array <op> 0-D array`` (or ``0-D array <op> array`` if ``scalar`` was the left-hand argument).
145144

146-
.. note::
147-
Behavior is not specified when mixing a Python ``float`` and an array with an integer data type; this may give ``float32``, ``float64``, or raise an exception. Behavior is implementation-specific.
145+
Additionally, using Python ``complex`` scalars together with arrays must be supported for:
146+
147+
- ``array <op> scalar``
148+
- ``scalar <op> array``
149+
150+
where ``<op>`` is a built-in operator (including in-place operators, but excluding the matmul ``@`` operator; see :ref:`operators` for operators supported by the array object) and ``scalar`` has a type and value compatible with a promoted array data type:
151+
152+
- a Python ``complex`` for real-valued floating-point array data types.
153+
154+
Provided the above requirements are met, the expected behavior is equivalent to:
155+
156+
1. Convert the scalar to a zero-dimensional array with a complex floating-point array data type having the same precision as that of the array operand used in the expression (e.g., if an array has a ``float32`` data type, the scalar must be converted to a zero-dimensional array having a ``complex64`` data type; if an array has a ``float64`` data type, the scalar must be converted to a zero-dimensional array have a ``complex128`` data type).
157+
2. Execute the operation for ``array <op> 0-D array`` (or ``0-D array <op> array`` if ``scalar`` was the left-hand argument).
158+
159+
Behavior is not specified for integers outside of the bounds of a given integer data type. Integers outside of bounds may result in overflow or an error.
148160

149-
Similarly, behavior is not specified when mixing a Python ``complex`` and an array with a real-valued data type; this may give ``complex64``, ``complex128``, or raise an exception. Behavior is implementation-specific.
161+
Behavior is not specified when mixing a Python ``float`` and an array with an integer data type; this may give ``float32``, ``float64``, or raise an exception. Behavior is implementation-specific.
150162

151-
Behavior is also not specified for integers outside of the bounds of a given integer data type. Integers outside of bounds may result in overflow or an error.
163+
Behavior is not specified when mixing a Python ``complex`` and an array with an integer data type; this may give ``complex64``, ``complex128``, or raise an exception. Behavior is implementation-specific.

draft/searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)