Skip to content

docs: add note that cross-kind comparisons are undefined #822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -651,6 +657,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 @@ -772,6 +781,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 @@ -817,6 +829,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 @@ -943,6 +958,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 @@ -1118,6 +1118,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 @@ -1347,6 +1350,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 @@ -1368,6 +1375,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 @@ -1563,6 +1573,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 @@ -1584,6 +1597,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 @@ -2134,6 +2150,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
Loading