From 339bb88c9f2321f2df333653a069d2e5a9bfa03c Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sun, 27 Nov 2022 02:08:57 -0800 Subject: [PATCH] Add support for complex number subtraction --- spec/API_specification/array_api/array_object.py | 8 +++++--- spec/API_specification/array_api/elementwise_functions.py | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/spec/API_specification/array_api/array_object.py b/spec/API_specification/array_api/array_object.py index cc24a3bbe..b45e08d8d 100644 --- a/spec/API_specification/array_api/array_object.py +++ b/spec/API_specification/array_api/array_object.py @@ -914,14 +914,16 @@ def __setitem__(self: array, key: Union[int, slice, ellipsis, Tuple[Union[int, s def __sub__(self: array, other: Union[int, float, array], /) -> array: """ - 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__`). + 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__`). Parameters ---------- self: array - array instance (minuend array). Should have a real-valued data type. + array instance (minuend array). Should have a numeric data type. other: Union[int, float, array] - subtrahend array. Must be compatible with ``self`` (see :ref:`broadcasting`). Should have a real-valued data type. + subtrahend array. Must be compatible with ``self`` (see :ref:`broadcasting`). Should have a numeric data type. Returns ------- diff --git a/spec/API_specification/array_api/elementwise_functions.py b/spec/API_specification/array_api/elementwise_functions.py index e76be8d65..3a5335052 100644 --- a/spec/API_specification/array_api/elementwise_functions.py +++ b/spec/API_specification/array_api/elementwise_functions.py @@ -1535,14 +1535,16 @@ def sqrt(x: array, /) -> array: def subtract(x1: array, x2: array, /) -> array: """ - 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`). + 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`). Parameters ---------- x1: array - first input array. Should have a real-valued data type. + first input array. Should have a numeric data type. x2: array - second input array. Must be compatible with ``x1`` (see :ref:`broadcasting`). Should have a real-valued data type. + second input array. Must be compatible with ``x1`` (see :ref:`broadcasting`). Should have a numeric data type. Returns -------