Skip to content

Commit 15e37c9

Browse files
authored
Add real specification for returning the real component of a complex number (#427)
* Add initial stub * Update copy concerning input and output array data types * Update index * Fix missing export
1 parent 67ab474 commit 15e37c9

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

Diff for: spec/API_specification/array_api/elementwise_functions.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,21 @@ def pow(x1: array, x2: array, /) -> array:
11811181
an array containing the element-wise results. The returned array must have a data type determined by :ref:`type-promotion`.
11821182
"""
11831183

1184+
def real(x: array, /) -> array:
1185+
"""
1186+
Returns the real component of a complex number for each element ``x_i`` of the input array ``x``.
1187+
1188+
Parameters
1189+
----------
1190+
x: array
1191+
input array. Should have a complex floating-point data type.
1192+
1193+
Returns
1194+
-------
1195+
out: array
1196+
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``).
1197+
"""
1198+
11841199
def remainder(x1: array, x2: array, /) -> array:
11851200
"""
11861201
Returns the remainder of division for each element ``x1_i`` of the input array ``x1`` and the respective element ``x2_i`` of the input array ``x2``.
@@ -1567,4 +1582,4 @@ def trunc(x: array, /) -> array:
15671582
an array containing the rounded result for each element in ``x``. The returned array must have the same data type as ``x``.
15681583
"""
15691584

1570-
__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', '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', 'remainder', 'round', 'sign', 'sin', 'sinh', 'square', 'sqrt', 'subtract', 'tan', 'tanh', 'trunc']
1585+
__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', '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']

Diff for: spec/API_specification/elementwise_functions.rst

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Objects in API
7373
not_equal
7474
positive
7575
pow
76+
real
7677
remainder
7778
round
7879
sign

0 commit comments

Comments
 (0)