Skip to content

Commit c8048d3

Browse files
committed
Refer to existing "mix scalars and arrays" section
1 parent 252331a commit c8048d3

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

spec/draft/API_specification/type_promotion.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ Notes
120120
.. note::
121121
Mixed integer and floating-point type promotion rules are not specified because behavior varies between implementations.
122122

123+
124+
.. _mixing-scalars-and-arrays:
123125
Mixing arrays with Python scalars
124126
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
125127

src/array_api_stubs/_draft/searching_functions.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,21 @@ def where(
151151
Parameters
152152
----------
153153
condition: array
154-
when ``True``, yield ``x1_i`` (scalar ``x1``); otherwise, yield ``x2_i`` (scalar ``x2``). Must be compatible with ``x1`` and ``x2`` (see :ref:`broadcasting`).
155-
x1: Union[array, int, float, bool]
156-
first input array or scalar. Must be compatible with ``condition`` and ``x2`` (see :ref:`broadcasting`).
157-
x2: Union[array, int, float, bool]
158-
second input array or scalar. Must be compatible with ``condition`` and ``x1`` (see :ref:`broadcasting`).
154+
when ``True``, yield ``x1_i``; otherwise, yield ``x2_i``. Must be compatible with ``x1`` and ``x2`` (see :ref:`broadcasting`).
155+
x1: Union[array, int, float, complex, bool]
156+
first input array or scalar. Scalar values are treated like an array filled with this value. Must be compatible with ``condition`` and ``x2`` (see :ref:`broadcasting`).
157+
x2: Union[array, int, float, complex, bool]
158+
second input array or scalar. Scalar values are treated like an array filled with this value. Must be compatible with ``condition`` and ``x1`` (see :ref:`broadcasting`).
159159
160160
Returns
161161
-------
162162
out: array
163163
an array with elements from ``x1`` where ``condition`` is ``True``, and elements from ``x2`` elsewhere. The returned array must have a data type determined by :ref:`type-promotion` rules with the arrays ``x1`` and ``x2``.
164164
165+
Notes
166+
-----
167+
See :ref:`mixing-scalars-and-arrays` on compatibility requirements and handling of scalar arguments for ``x1`` and ``x2``.
168+
165169
.. versionchanged:: 2024.12
166170
``x1`` and ``x2`` may be scalars.
167171
"""

0 commit comments

Comments
 (0)