Skip to content

Commit

Permalink
docs: add note that cross-kind comparisons are undefined
Browse files Browse the repository at this point in the history
PR-URL: #822
Closes: #819
Co-authored-by: Athan Reines <kgryte@gmail.com>
Reviewed-by: Athan Reines <kgryte@gmail.com>
  • Loading branch information
asmeurer and kgryte authored Oct 31, 2024
1 parent c28d3c5 commit 6d205d7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/array_api_stubs/_draft/array_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,9 @@ def __eq__(self: array, other: Union[int, float, bool, array], /) -> array:
.. note::
Element-wise results, including special cases, must equal the results returned by the equivalent element-wise function :func:`~array_api.equal`.
.. note::
Comparison of arrays without a corresponding promotable data type (see :ref:`type-promotion`) is undefined and thus implementation-dependent.
"""

def __float__(self: array, /) -> float:
Expand Down Expand Up @@ -599,6 +602,9 @@ def __ge__(self: array, other: Union[int, float, array], /) -> array:
.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.greater_equal`.
.. note::
Comparison of arrays without a corresponding promotable data type (see :ref:`type-promotion`) is undefined and thus implementation-dependent.
"""

def __getitem__(
Expand Down Expand Up @@ -657,6 +663,9 @@ def __gt__(self: array, other: Union[int, float, array], /) -> array:
.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.greater`.
.. note::
Comparison of arrays without a corresponding promotable data type (see :ref:`type-promotion`) is undefined and thus implementation-dependent.
"""

def __index__(self: array, /) -> int:
Expand Down Expand Up @@ -778,6 +787,9 @@ def __le__(self: array, other: Union[int, float, array], /) -> array:
.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.less_equal`.
.. note::
Comparison of arrays without a corresponding promotable data type (see :ref:`type-promotion`) is undefined and thus implementation-dependent.
"""

def __lshift__(self: array, other: Union[int, array], /) -> array:
Expand Down Expand Up @@ -823,6 +835,9 @@ def __lt__(self: array, other: Union[int, float, array], /) -> array:
.. note::
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.less`.
.. note::
Comparison of arrays without a corresponding promotable data type (see :ref:`type-promotion`) is undefined and thus implementation-dependent.
"""

def __matmul__(self: array, other: array, /) -> array:
Expand Down Expand Up @@ -949,6 +964,9 @@ def __ne__(self: array, other: Union[int, float, bool, array], /) -> array:
.. note::
Element-wise results, including special cases, must equal the results returned by the equivalent element-wise function :func:`~array_api.not_equal`.
.. note::
Comparison of arrays without a corresponding promotable data type (see :ref:`type-promotion`) is undefined and thus implementation-dependent.
.. versionchanged:: 2022.12
Added complex data type support.
"""
Expand Down
19 changes: 19 additions & 0 deletions src/array_api_stubs/_draft/elementwise_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,9 @@ def equal(x1: array, x2: array, /) -> array:
.. note::
For discussion of complex number equality, see :ref:`complex-numbers`.
.. note::
Comparison of arrays without a corresponding promotable data type (see :ref:`type-promotion`) is undefined and thus implementation-dependent.
.. versionchanged:: 2022.12
Added complex data type support.
"""
Expand Down Expand Up @@ -1354,6 +1357,10 @@ def greater(x1: array, x2: array, /) -> array:
-------
out: array
an array containing the element-wise results. The returned array must have a data type of ``bool``.
.. note::
Comparison of arrays without a corresponding promotable data type (see :ref:`type-promotion`) is undefined and thus implementation-dependent.
"""


Expand All @@ -1375,6 +1382,9 @@ def greater_equal(x1: array, x2: array, /) -> array:
-------
out: array
an array containing the element-wise results. The returned array must have a data type of ``bool``.
.. note::
Comparison of arrays without a corresponding promotable data type (see :ref:`type-promotion`) is undefined and thus implementation-dependent.
"""


Expand Down Expand Up @@ -1570,6 +1580,9 @@ def less(x1: array, x2: array, /) -> array:
-------
out: array
an array containing the element-wise results. The returned array must have a data type of ``bool``.
.. note::
Comparison of arrays without a corresponding promotable data type (see :ref:`type-promotion`) is undefined and thus implementation-dependent.
"""


Expand All @@ -1591,6 +1604,9 @@ def less_equal(x1: array, x2: array, /) -> array:
-------
out: array
an array containing the element-wise results. The returned array must have a data type of ``bool``.
.. note::
Comparison of arrays without a corresponding promotable data type (see :ref:`type-promotion`) is undefined and thus implementation-dependent.
"""


Expand Down Expand Up @@ -2141,6 +2157,9 @@ def not_equal(x1: array, x2: array, /) -> array:
.. note::
For discussion of complex number equality, see :ref:`complex-numbers`.
.. note::
Comparison of arrays without a corresponding promotable data type (see :ref:`type-promotion`) is undefined and thus implementation-dependent.
.. versionchanged:: 2022.12
Added complex data type support.
"""
Expand Down

0 comments on commit 6d205d7

Please sign in to comment.