Skip to content

Commit 095e8d0

Browse files
committed
docs: add note concerning the use of isnan
1 parent d0d02c6 commit 095e8d0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/array_api_stubs/_draft/statistical_functions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,14 @@ def mean(
137137
- If ``N`` is ``0``, the arithmetic mean is ``NaN``.
138138
- If ``x_i`` is ``NaN``, the arithmetic mean is ``NaN`` (i.e., ``NaN`` values propagate).
139139
140-
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
140+
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
141141
142142
- If ``N`` is ``0``, the arithmetic mean is ``NaN + NaN j``.
143143
- If ``a`` is ``NaN``, the real component of the result is ``NaN``.
144144
- Similarly, if ``b`` is ``NaN``, the imaginary component of the result is ``NaN``.
145+
146+
.. note::
147+
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.
145148
"""
146149

147150

0 commit comments

Comments
 (0)