8000 feat: add complex dtype support for `mean` by kgryte · Pull Request #850 · data-apis/array-api · GitHub
[go: up one dir, main page]

Skip to content

feat: add complex dtype support for mean #850

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 2 commits into from
Dec 12, 2024
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
Prev Previous commit
docs: add note concerning the use of isnan
  • Loading branch information
kgryte committed Dec 12, 2024
commit 095e8d0ad891d5972ff7704948be8549e87a38ae
5 changes: 4 additions & 1 deletion src/array_api_stubs/_draft/statistical_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,14 @@ def mean(
- If ``N`` is ``0``, the arithmetic mean is ``NaN``.
- If ``x_i`` is ``NaN``, the arithmetic mean is ``NaN`` (i.e., ``NaN`` values propagate).

For complex floating-point operands, real-valued floating-point special cases must independently apply to the real and imaginary component operations involving real numbers. For example, let ``a = real(x_i)`` and ``b = imag(x_i)``, and
For complex floating-point operands, real-valued floating-point special cases should independently apply to the real and imaginary component operations involving real numbers. For example, let ``a = real(x_i)`` and ``b = imag(x_i)``, and

- If ``N`` is ``0``, the arithmetic mean is ``NaN + NaN j``.
- If ``a`` is ``NaN``, the real component of the result is ``NaN``.
- Similarly, if ``b`` is ``NaN``, the imaginary component of the result is ``NaN``.

.. note::
Array libraries, such as NumPy, PyTorch, and JAX, currently deviate from this specification in their handling of components which are ``NaN`` when computing the arithmetic mean. In general, consumers of array libraries implementing this specification should use :func:`~array_api.isnan` to test whether the result of computing the arithmetic mean over an array have a complex floating-point data type is ``NaN``, rather than relying on ``NaN`` propagation of individual components.
"""


Expand Down
Loading
0