Skip to content

Commit 58580d5

Browse files
authored
Add support for complex number subtraction (#526)
1 parent 8062655 commit 58580d5

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

spec/API_specification/array_api/array_object.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -947,14 +947,16 @@ def __setitem__(self: array, key: Union[int, slice, ellipsis, Tuple[Union[int, s
947947

948948
def __sub__(self: array, other: Union[int, float, array], /) -> array:
949949
"""
950-
Calculates the difference for each element of an array instance with the respective element of the array ``other``. The result of ``self_i - other_i`` must be the same as ``self_i + (-other_i)`` and must be governed by the same floating-point rules as addition (see :meth:`array.__add__`).
950+
Calculates the difference for each element of an array instance with the respective element of the array ``other``.
951+
952+
The result of ``self_i - other_i`` must be the same as ``self_i + (-other_i)`` and must be governed by the same floating-point rules as addition (see :meth:`array.__add__`).
951953
952954
Parameters
953955
----------
954956
self: array
955-
array instance (minuend array). Should have a real-valued data type.
957+
array instance (minuend array). Should have a numeric data type.
956958
other: Union[int, float, array]
957-
subtrahend array. Must be compatible with ``self`` (see :ref:`broadcasting`). Should have a real-valued data type.
959+
subtrahend array. Must be compatible with ``self`` (see :ref:`broadcasting`). Should have a numeric data type.
958960
959961
Returns
960962
-------

spec/API_specification/array_api/elementwise_functions.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1826,14 +1826,16 @@ def sqrt(x: array, /) -> array:
18261826

18271827
def subtract(x1: array, x2: array, /) -> array:
18281828
"""
1829-
Calculates the difference for each element ``x1_i`` of the input array ``x1`` with the respective element ``x2_i`` of the input array ``x2``. The result of ``x1_i - x2_i`` must be the same as ``x1_i + (-x2_i)`` and must be governed by the same floating-point rules as addition (see :meth:`add`).
1829+
Calculates the difference for each element ``x1_i`` of the input array ``x1`` with the respective element ``x2_i`` of the input array ``x2``.
1830+
1831+
The result of ``x1_i - x2_i`` must be the same as ``x1_i + (-x2_i)`` and must be governed by the same floating-point rules as addition (see :meth:`add`).
18301832
18311833
Parameters
18321834
----------
18331835
x1: array
1834-
first input array. Should have a real-valued data type.
1836+
first input array. Should have a numeric data type.
18351837
x2: array
1836-
second input array. Must be compatible with ``x1`` (see :ref:`broadcasting`). Should have a real-valued data type.
1838+
second input array. Must be compatible with ``x1`` (see :ref:`broadcasting`). Should have a numeric data type.
18371839
18381840
Returns
18391841
-------

0 commit comments

Comments
 (0)