Utility Functions ¶
Array API specification for utility functions.
A conforming implementation of the array API standard must provide and support the following functions adhering to the following conventions.

Positional parameters must be positionalonly parameters. Positionalonly parameters have no externallyusable name. When a function accepting positionalonly parameters is called, positional arguments are mapped to these parameters based solely on their order.

Optional parameters must be keywordonly arguments.

Broadcasting semantics must follow the semantics defined in Broadcasting .

Unless stated otherwise, functions must support the data types defined in Data Types .

Unless stated otherwise, functions must adhere to the type promotion rules defined in Type Promotion Rules .

Unless stated otherwise, floatingpoint operations must adhere to IEEE 7542019.
Objects in API ¶
all(x, /, *, axis=None, keepdims=False) ¶
Tests whether all input array elements evaluate to
True
along a specified axis.
Parameters ¶

x : <array>

input array.


axis : Optional[ Union[ int, Tuple[ int, … ] ] ]

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)
, whereN
is the rank (number of dimensions) ofx
. If anaxis
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 (where1
refers to the last dimension). If provided an invalidaxis
, the function must raise an exception. Default:None
.


keepdims : bool

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 Broadcasting ). Otherwise, ifFalse
, the reduced axes (dimensions) must not be included in the result. Default:False
.

Returns ¶

out : <array>

if a logical AND reduction was performed over the entire array, the returned array must be a zerodimensional array containing the test result; otherwise, the returned array must be a nonzerodimensional array containing the test results. The returned array must have a data type of
bool
.

any(x, /, *, axis=None, keepdims=False) ¶
Tests whether any input array element evaluates to
True
along a specified axis.
Parameters ¶

x : <array>

input array.


axis : Optional[ Union[ int, Tuple[ int, … ] ] ]

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)
, whereN
is the rank (number of dimensions) ofx
. If anaxis
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 (where1
refers to the last dimension). If provided an invalidaxis
, the function must raise an exception. Default:None
.


keepdims : bool

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 Broadcasting ). Otherwise, ifFalse
, the reduced axes (dimensions) must not be included in the result. Default:False
.

Returns ¶

out : <array>

if a logical OR reduction was performed over the entire array, the returned array must be a zerodimensional array containing the test result; otherwise, the returned array must be a nonzerodimensional array containing the test results. The returned array must have a data type of
bool
.
