Skip to content

Commit 50ca679

Browse files
authored
Add specifications for maximum and minimum
Closes: data-apis#667 PR-URL: data-apis#713
1 parent bda9c48 commit 50ca679

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

Diff for: spec/draft/API_specification/elementwise_functions.rst

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ Objects in API
6060
logical_not
6161
logical_or
6262
logical_xor
63+
maximum
64+
minimum
6365
multiply
6466
negative
6567
not_equal

Diff for: src/array_api_stubs/_draft/elementwise_functions.py

+62
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
"logical_not",
4343
"logical_or",
4444
"logical_xor",
45+
"maximum",
46+
"minimum",
4547
"multiply",
4648
"negative",
4749
"not_equal",
@@ -1820,6 +1822,66 @@ def logical_xor(x1: array, x2: array, /) -> array:
18201822
"""
18211823

18221824

1825+
def maximum(x1: array, x2: array, /) -> array:
1826+
r"""
1827+
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``.
1828+
1829+
.. note::
1830+
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`).
1831+
1832+
Parameters
1833+
----------
1834+
x1: array
1835+
first input array. Should have a real-valued data type.
1836+
x2: array
1837+
second input array. Must be compatible with ``x1`` (see :ref:`broadcasting`). Should have a real-valued data type.
1838+
1839+
Returns
1840+
-------
1841+
out: array
1842+
an array containing the element-wise maximum values. The returned array must have a data type determined by :ref:`type-promotion`.
1843+
1844+
Notes
1845+
-----
1846+
1847+
**Special Cases**
1848+
1849+
For floating-point operands,
1850+
1851+
- If either ``x1_i`` or ``x2_i`` is ``NaN``, the result is ``NaN``.
1852+
"""
1853+
1854+
1855+
def minimum(x1: array, x2: array, /) -> array:
1856+
r"""
1857+
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``.
1858+
1859+
.. note::
1860+
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`).
1861+
1862+
Parameters
1863+
----------
1864+
x1: array
1865+
first input array. Should have a real-valued data type.
1866+
x2: array
1867+
second input array. Must be compatible with ``x1`` (see :ref:`broadcasting`). Should have a real-valued data type.
1868+
1869+
Returns
1870+
-------
1871+
out: array
1872+
an array containing the element-wise minimum values. The returned array must have a data type determined by :ref:`type-promotion`.
1873+
1874+
Notes
1875+
-----
1876+
1877+
**Special Cases**
1878+
1879+
For floating-point operands,
1880+
1881+
- If either ``x1_i`` or ``x2_i`` is ``NaN``, the result is ``NaN``.
1882+
"""
1883+
1884+
18231885
def multiply(x1: array, x2: array, /) -> array:
18241886
r"""
18251887
Calculates the product for each element ``x1_i`` of the input array ``x1`` with the respective element ``x2_i`` of the input array ``x2``.

0 commit comments

Comments
 (0)