Skip to content

Commit 3c0d3ee

Browse files
authored
Add imag specification for returning the imaginary component of a complex number (#496)
* Add specification for returning the imaginary component for each element of a complex number array * Update API list
1 parent 8949817 commit 3c0d3ee

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

spec/API_specification/array_api/elementwise_functions.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,21 @@ def greater_equal(x1: array, x2: array, /) -> array:
785785
an array containing the element-wise results. The returned array must have a data type of ``bool``.
786786
"""
787787

788+
def imag(x: array, /) -> array:
789+
"""
790+
Returns the imaginary component of a complex number for each element ``x_i`` of the input array ``x``.
791+
792+
Parameters
793+
----------
794+
x: array
795+
input array. Should have a complex floating-point data type.
796+
797+
Returns
798+
-------
799+
out: array
800+
an array containing the element-wise results. The returned array must have a floating-point data type with the same floating-point precision as ``x`` (e.g., if ``x`` is ``complex64``, the returned array must have the floating-point data type ``float32``).
801+
"""
802+
788803
def isfinite(x: array, /) -> array:
789804
"""
790805
Tests each element ``x_i`` of the input array ``x`` to determine if finite (i.e., not ``NaN`` and not equal to positive or negative infinity).
@@ -1610,4 +1625,4 @@ def trunc(x: array, /) -> array:
16101625
an array containing the rounded result for each element in ``x``. The returned array must have the same data type as ``x``.
16111626
"""
16121627

1613-
__all__ = ['abs', 'acos', 'acosh', 'add', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'bitwise_and', 'bitwise_left_shift', 'bitwise_invert', 'bitwise_or', 'bitwise_right_shift', 'bitwise_xor', 'ceil', 'conj', 'cos', 'cosh', 'divide', 'equal', 'exp', 'expm1', 'floor', 'floor_divide', 'greater', 'greater_equal', 'isfinite', 'isinf', 'isnan', 'less', 'less_equal', 'log', 'log1p', 'log2', 'log10', 'logaddexp', 'logical_and', 'logical_not', 'logical_or', 'logical_xor', 'multiply', 'negative', 'not_equal', 'positive', 'pow', 'real', 'remainder', 'round', 'sign', 'sin', 'sinh', 'square', 'sqrt', 'subtract', 'tan', 'tanh', 'trunc']
1628+
__all__ = ['abs', 'acos', 'acosh', 'add', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'bitwise_and', 'bitwise_left_shift', 'bitwise_invert', 'bitwise_or', 'bitwise_right_shift', 'bitwise_xor', 'ceil', 'conj', 'cos', 'cosh', 'divide', 'equal', 'exp', 'expm1', 'floor', 'floor_divide', 'greater', 'greater_equal', 'imag', 'isfinite', 'isinf', 'isnan', 'less', 'less_equal', 'log', 'log1p', 'log2', 'log10', 'logaddexp', 'logical_and', 'logical_not', 'logical_or', 'logical_xor', 'multiply', 'negative', 'not_equal', 'positive', 'pow', 'real', 'remainder', 'round', 'sign', 'sin', 'sinh', 'square', 'sqrt', 'subtract', 'tan', 'tanh', 'trunc']

0 commit comments

Comments
 (0)