Skip to content
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

Allow lazy implementations to raise from intrinsically eager functions #652

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Changes from 1 commit
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
22 changes: 22 additions & 0 deletions src/array_api_stubs/_draft/array_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ def __bool__(self: array, /) -> bool:

For complex floating-point operands, special cases must be handled as if the operation is implemented as the logical AND of ``bool(real(self))`` and ``bool(imag(self))``.

**Lazy implemenations**

Lazy implementations of the API standard must raise a ``ValueError`` if they are unable eagerly compute the requested value.

.. versionchanged:: 2022.12
Added boolean and complex data type support.
"""
Expand Down Expand Up @@ -422,6 +426,10 @@ def __float__(self: array, /) -> float:
- If ``self`` is ``True``, the result is ``1``.
- If ``self`` is ``False``, the result is ``0``.

**Lazy implementations**

Lazy implementations of the API standard must raise a ``ValueError`` if they are unable eagerly compute the requested value.

.. versionchanged:: 2022.12
Added boolean and complex data type support.
"""
Expand Down Expand Up @@ -537,6 +545,13 @@ def __index__(self: array, /) -> int:
-------
out: int
a Python ``int`` object representing the single element of the array instance.

Notes
-----

**Lazy implementations**

Lazy implementations of the API standard must raise a ``ValueError`` if they are unable eagerly compute the requested value.
"""

def __int__(self: array, /) -> int:
Expand Down Expand Up @@ -575,6 +590,13 @@ def __int__(self: array, /) -> int:
- If ``self`` is either ``+infinity`` or ``-infinity``, raise ``OverflowError``.
- If ``self`` is ``NaN``, raise ``ValueError``.

Notes
-----

**Lazy implementations**

Lazy implementations of the API standard must raise a ``ValueError`` if they are unable eagerly compute the requested value.

.. versionchanged:: 2022.12
Added boolean and complex data type support.
"""
Expand Down