Skip to content

Commit

Permalink
Add specifications for maximum and minimum
Browse files Browse the repository at this point in the history
Closes: #667
PR-URL: 	#713
  • Loading branch information
kgryte authored Dec 14, 2023
1 parent bda9c48 commit 50ca679
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
2 changes: 2 additions & 0 deletions spec/draft/API_specification/elementwise_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ Objects in API
logical_not
logical_or
logical_xor
maximum
minimum
multiply
negative
not_equal
Expand Down
62 changes: 62 additions & 0 deletions src/array_api_stubs/_draft/elementwise_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
"logical_not",
"logical_or",
"logical_xor",
"maximum",
"minimum",
"multiply",
"negative",
"not_equal",
Expand Down Expand Up @@ -1820,6 +1822,66 @@ def logical_xor(x1: array, x2: array, /) -> array:
"""


def maximum(x1: array, x2: array, /) -> array:
r"""
Computes the maximum value for each element ``x1_i`` of the input array ``x1`` relative to the respective element ``x2_i`` of the input array ``x2``.
.. note::
For backward compatibility, conforming implementations may support complex numbers; however, inequality comparison of complex numbers is unspecified and thus implementation-dependent (see :ref:`complex-number-ordering`).
Parameters
----------
x1: array
first input array. Should have a real-valued data type.
x2: array
second input array. Must be compatible with ``x1`` (see :ref:`broadcasting`). Should have a real-valued data type.
Returns
-------
out: array
an array containing the element-wise maximum values. The returned array must have a data type determined by :ref:`type-promotion`.
Notes
-----
**Special Cases**
For floating-point operands,
- If either ``x1_i`` or ``x2_i`` is ``NaN``, the result is ``NaN``.
"""


def minimum(x1: array, x2: array, /) -> array:
r"""
Computes the minimum value for each element ``x1_i`` of the input array ``x1`` relative to the respective element ``x2_i`` of the input array ``x2``.
.. note::
For backward compatibility, conforming implementations may support complex numbers; however, inequality comparison of complex numbers is unspecified and thus implementation-dependent (see :ref:`complex-number-ordering`).
Parameters
----------
x1: array
first input array. Should have a real-valued data type.
x2: array
second input array. Must be compatible with ``x1`` (see :ref:`broadcasting`). Should have a real-valued data type.
Returns
-------
out: array
an array containing the element-wise minimum values. The returned array must have a data type determined by :ref:`type-promotion`.
Notes
-----
**Special Cases**
For floating-point operands,
- If either ``x1_i`` or ``x2_i`` is ``NaN``, the result is ``NaN``.
"""


def multiply(x1: array, x2: array, /) -> array:
r"""
Calculates the product for each element ``x1_i`` of the input array ``x1`` with the respective element ``x2_i`` of the input array ``x2``.
Expand Down

0 comments on commit 50ca679

Please sign in to comment.