Skip to content

Commit 1d9ee15

Browse files
authored
Merge pull request #372 from steff456/utilityfunc-rst
PR: Transform utility functions md to rst
2 parents d446b85 + dc946da commit 1d9ee15

File tree

3 files changed

+68
-66
lines changed

3 files changed

+68
-66
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from ._types import Optional, Tuple, Union, array
2+
3+
def all(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keepdims: bool = False) -> array:
4+
"""
5+
Tests whether all input array elements evaluate to ``True`` along a specified axis.
6+
7+
Parameters
8+
----------
9+
x: array
10+
input array.
11+
axis: Optional[Union[int, Tuple[int, ...]]]
12+
axis or axes along which to perform a logical AND reduction. By default, a logical AND reduction must be performed over the entire array. If a tuple of integers, logical AND reductions must be performed over multiple axes. A valid ``axis`` must be an integer on the interval ``[-N, N)``, where ``N`` is the rank (number of dimensions) of ``x``. If an ``axis`` is specified as a negative integer, the function must determine the axis along which to perform a reduction by counting backward from the last dimension (where ``-1`` refers to the last dimension). If provided an invalid ``axis``, the function must raise an exception. Default: ``None``.
13+
keepdims: bool
14+
If ``True``, the reduced axes (dimensions) must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see :ref:`broadcasting`). Otherwise, if ``False``, the reduced axes (dimensions) must not be included in the result. Default: ``False``.
15+
16+
Returns
17+
-------
18+
out: array
19+
if a logical AND reduction was performed over the entire array, the returned array must be a zero-dimensional array containing the test result; otherwise, the returned array must be a non-zero-dimensional array containing the test results. The returned array must have a data type of ``bool``.
20+
"""
21+
22+
def any(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keepdims: bool = False) -> array:
23+
"""
24+
Tests whether any input array element evaluates to ``True`` along a specified axis.
25+
26+
Parameters
27+
----------
28+
x: array
29+
input array.
30+
axis: Optional[Union[int, Tuple[int, ...]]]
31+
axis or axes along which to perform a logical OR reduction. By default, a logical OR reduction must be performed over the entire array. If a tuple of integers, logical OR reductions must be performed over multiple axes. A valid ``axis`` must be an integer on the interval ``[-N, N)``, where ``N`` is the rank (number of dimensions) of ``x``. If an ``axis`` is specified as a negative integer, the function must determine the axis along which to perform a reduction by counting backward from the last dimension (where ``-1`` refers to the last dimension). If provided an invalid ``axis``, the function must raise an exception. Default: ``None``.
32+
keepdims: bool
33+
If ``True``, the reduced axes (dimensions) must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see :ref:`broadcasting`). Otherwise, if ``False``, the reduced axes (dimensions) must not be included in the result. Default: ``False``.
34+
35+
Returns
36+
-------
37+
out: array
38+
if a logical OR reduction was performed over the entire array, the returned array must be a zero-dimensional array containing the test result; otherwise, the returned array must be a non-zero-dimensional array containing the test results. The returned array must have a data type of ``bool``.
39+
"""
40+
41+
__all__ = ['all', 'any']

spec/API_specification/utility_functions.md

-66
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Utility Functions
2+
=================
3+
4+
Array API specification for utility functions.
5+
6+
A conforming implementation of the array API standard must provide and support the following functions adhering to the following conventions.
7+
8+
- Positional parameters must be `positional-only <https://www.python.org/dev/peps/pep-0570/>`_ parameters. Positional-only parameters have no externally-usable name. When a function accepting positional-only parameters is called, positional arguments are mapped to these parameters based solely on their order.
9+
- Optional parameters must be `keyword-only <https://www.python.org/dev/peps/pep-3102/>`_ arguments.
10+
- Broadcasting semantics must follow the semantics defined in :ref:`broadcasting`.
11+
- Unless stated otherwise, functions must support the data types defined in :ref:`data-types`.
12+
- Unless stated otherwise, functions must adhere to the type promotion rules defined in :ref:`type-promotion`.
13+
- Unless stated otherwise, floating-point operations must adhere to IEEE 754-2019.
14+
15+
Objects in API
16+
--------------
17+
18+
.. currentmodule:: signatures.utility_functions
19+
20+
..
21+
NOTE: please keep the functions in alphabetical order
22+
23+
.. autosummary::
24+
:toctree: generated
25+
26+
all
27+
any

0 commit comments

Comments
 (0)