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

Add complex number support to round #440

Merged
merged 2 commits into from
Jul 7, 2022
Merged
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
10 changes: 9 additions & 1 deletion spec/API_specification/array_api/elementwise_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1163,8 +1163,16 @@ def round(x: array, /) -> array:
"""
Rounds each element ``x_i`` of the input array ``x`` to the nearest integer-valued number.

.. note::
For complex floating-point operands, real and imaginary components must be independently rounded to the nearest integer-valued number.

Rounded real and imaginary components must be equal to their equivalent rounded real-valued floating-point counterparts (i.e., for complex-valued ``x``, ``real(round(x))`` must equal ``round(real(x)))`` and ``imag(round(x))`` must equal ``round(imag(x))``).

**Special cases**

.. note::
For complex floating-point operands, the following special cases apply to real and imaginary components independently (e.g., if ``real(x_i)`` is ``NaN``, the rounded real component is ``NaN``).

- If ``x_i`` is already integer-valued, the result is ``x_i``.

For floating-point operands,
Expand All @@ -1179,7 +1187,7 @@ def round(x: array, /) -> array:
Parameters
----------
x: array
input array. Should have a real-valued data type.
input array. Should have a numeric data type.

Returns
-------
Expand Down