Skip to content

Commit a6eb99e

Browse files
authored
Merge branch 'main' into rfc_should_must
2 parents 699a1d6 + d12a5e3 commit a6eb99e

File tree

8 files changed

+40
-16
lines changed

8 files changed

+40
-16
lines changed

spec/draft/API_specification/type_promotion.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ 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:
125+
123126
Mixing arrays with Python scalars
124127
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
125128

src/array_api_stubs/_2021_12/linalg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ def trace(x: array, /, *, offset: int = 0) -> array:
474474
"""
475475

476476

477-
def vecdot(x1: array, x2: array, /, *, axis: int = None) -> array:
477+
def vecdot(x1: array, x2: array, /, *, axis: int = -1) -> array:
478478
"""
479479
Alias for :func:`~array_api.vecdot`.
480480
"""

src/array_api_stubs/_2022_12/linalg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ def trace(x: array, /, *, offset: int = 0, dtype: Optional[dtype] = None) -> arr
755755
"""
756756

757757

758-
def vecdot(x1: array, x2: array, /, *, axis: int = None) -> array:
758+
def vecdot(x1: array, x2: array, /, *, axis: int = -1) -> array:
759759
"""Alias for :func:`~array_api.vecdot`."""
760760

761761

src/array_api_stubs/_2023_12/linalg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ def trace(x: array, /, *, offset: int = 0, dtype: Optional[dtype] = None) -> arr
781781
"""
782782

783783

784-
def vecdot(x1: array, x2: array, /, *, axis: int = None) -> array:
784+
def vecdot(x1: array, x2: array, /, *, axis: int = -1) -> array:
785785
"""Alias for :func:`~array_api.vecdot`."""
786786

787787

src/array_api_stubs/_draft/data_type_functions.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,20 +209,25 @@ def isdtype(
209209
"""
210210

211211

212-
def result_type(*arrays_and_dtypes: Union[array, dtype]) -> dtype:
212+
def result_type(
213+
*arrays_and_dtypes: Union[array, int, float, complex, bool, dtype]
214+
) -> dtype:
213215
"""
214-
Returns the dtype that results from applying the type promotion rules (see :ref:`type-promotion`) to the arguments.
215-
216-
.. note::
217-
If provided mixed dtypes (e.g., integer and floating-point), the returned dtype will be implementation-specific.
216+
Returns the dtype that results from applying type promotion rules (see :ref:`type-promotion`) to the arguments.
218217
219218
Parameters
220219
----------
221-
arrays_and_dtypes: Union[array, dtype]
222-
an arbitrary number of input arrays and/or dtypes.
220+
arrays_and_dtypes: Union[array, int, float, complex, bool, dtype]
221+
an arbitrary number of input arrays, scalars, and/or dtypes.
223222
224223
Returns
225224
-------
226225
out: dtype
227-
the dtype resulting from an operation involving the input arrays and dtypes.
226+
the dtype resulting from an operation involving the input arrays, scalars, and/or dtypes.
227+
228+
Notes
229+
-----
230+
231+
- At least one argument must be an array or a dtype.
232+
- If provided array and/or dtype arguments having mixed data type kinds (e.g., integer and floating-point), the returned dtype is unspecified and is implementation-dependent.
228233
"""

src/array_api_stubs/_draft/indexing_functions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def take(x: array, indices: array, /, *, axis: Optional[int] = None) -> array:
1313
Parameters
1414
----------
1515
x: array
16-
input array.
16+
input array. Should have one or more dimensions (axes).
1717
indices: array
1818
array indices. The array *must* be one-dimensional and have an integer data type.
1919
@@ -33,6 +33,8 @@ def take(x: array, indices: array, /, *, axis: Optional[int] = None) -> array:
3333
Notes
3434
-----
3535
36+
- When ``x`` is a zero-dimensional array, behavior is unspecified and thus implementation-defined.
37+
3638
.. versionadded:: 2022.12
3739
3840
.. versionchanged:: 2023.12

src/array_api_stubs/_draft/linalg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ def trace(x: array, /, *, offset: int = 0, dtype: Optional[dtype] = None) -> arr
781781
"""
782782

783783

784-
def vecdot(x1: array, x2: array, /, *, axis: int = None) -> array:
784+
def vecdot(x1: array, x2: array, /, *, axis: int = -1) -> array:
785785
"""Alias for :func:`~array_api.vecdot`."""
786786

787787

src/array_api_stubs/_draft/searching_functions.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,21 +168,35 @@ def searchsorted(
168168
"""
169169

170170

171-
def where(condition: array, x1: array, x2: array, /) -> array:
171+
def where(
172+
condition: array,
173+
x1: Union[array, int, float, complex, bool],
174+
x2: Union[array, int, float, complex, bool],
175+
/,
176+
) -> array:
172177
"""
173178
Returns elements chosen from ``x1`` or ``x2`` depending on ``condition``.
174179
175180
Parameters
176181
----------
177182
condition: array
178183
when ``True``, yield ``x1_i``; otherwise, yield ``x2_i``. Should have a boolean data type. Must be compatible with ``x1`` and ``x2`` (see :ref:`broadcasting`).
179-
x1: array
184+
x1: Union[array, int, float, complex, bool]
180185
first input array. Must be compatible with ``condition`` and ``x2`` (see :ref:`broadcasting`).
181-
x2: array
186+
x2: Union[array, int, float, complex, bool]
182187
second input array. Must be compatible with ``condition`` and ``x1`` (see :ref:`broadcasting`).
183188
184189
Returns
185190
-------
186191
out: array
187192
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``.
193+
194+
Notes
195+
-----
196+
197+
- At least one of ``x1`` and ``x2`` *must* be an array.
198+
- If either ``x1`` or ``x2`` is a scalar value, the returned array *must* have a data type determined according to :ref:`mixing-scalars-and-arrays`.
199+
200+
.. versionchanged:: 2024.12
201+
Added support for scalar arguments.
188202
"""

0 commit comments

Comments
 (0)