Skip to content

Commit a2a0e63

Browse files
committed
Merge branch 'main' of https://github.com/data-apis/array-api into feat/sqrt-accuracy
2 parents 2296a03 + 071780c commit a2a0e63

File tree

7 files changed

+346
-255
lines changed

7 files changed

+346
-255
lines changed

src/array_api_stubs/_2023_12/array_object.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def __dlpack__(
364364
``__dlpack__`` to return a capsule referencing an array whose underlying memory is
365365
accessible to the Python interpreter (represented by the ``kDLCPU`` enumerator in DLPack).
366366
If a copy must be made to enable this support but ``copy`` is set to ``False``, the
367-
function must raise ``ValueError``.
367+
function must raise ``BufferError``.
368368
369369
Other device kinds will be considered for standardization in a future version of this
370370
API standard.

src/array_api_stubs/_draft/array_object.py

Lines changed: 78 additions & 103 deletions
Large diffs are not rendered by default.

src/array_api_stubs/_draft/data_type_functions.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def astype(
6565

6666
def can_cast(from_: Union[dtype, array], to: dtype, /) -> bool:
6767
"""
68-
Determines if one data type can be cast to another data type according :ref:`type-promotion` rules.
68+
Determines if one data type can be cast to another data type according to type promotion rules (see :ref:`type-promotion`).
6969
7070
Parameters
7171
----------
@@ -77,7 +77,13 @@ def can_cast(from_: Union[dtype, array], to: dtype, /) -> bool:
7777
Returns
7878
-------
7979
out: bool
80-
``True`` if the cast can occur according to :ref:`type-promotion` rules; otherwise, ``False``.
80+
``True`` if the cast can occur according to type promotion rules (see :ref:`type-promotion`); otherwise, ``False``.
81+
82+
Notes
83+
-----
84+
85+
- When ``from_`` is a data type, the function must determine whether the data type can be cast to another data type according to the complete type promotion rules (see :ref:`type-promotion`) described in this specification, irrespective of whether a conforming array library supports devices which do not have full data type support.
86+
- When ``from_`` is an array, the function must determine whether the data type of the array can be cast to the desired data type according to the type promotion graph of the array device. As not all devices can support all data types, full support for type promotion rules (see :ref:`type-promotion`) may not be possible. Accordingly, the output of ``can_cast(array, dtype)`` may differ from ``can_cast(array.dtype, dtype)``.
8187
"""
8288

8389

@@ -229,5 +235,7 @@ def result_type(
229235
-----
230236
231237
- 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.
238+
- If provided array and/or dtype arguments having mixed data type kinds (e.g., integer and floating-point), the returned dtype is unspecified and thus implementation-dependent.
239+
- If at least one argument is an array, the function must determine the resulting dtype according to the type promotion graph of the array device which is shared among all array arguments. As not all devices can support all data types, full support for type promotion rules (see :ref:`type-promotion`) may not be possible. Accordingly, the returned dtype may differ from that determined from the complete type promotion graph defined in this specification (see :ref:`type-promotion`).
240+
- If two or more arguments are arrays belonging to different devices, behavior is unspecified and thus implementation-dependent. Conforming implementations may choose to ignore device attributes, raise an exception, or some other behavior.
233241
"""

0 commit comments

Comments
 (0)