diff --git a/spec/API_specification/data_type_functions.md b/spec/API_specification/data_type_functions.md new file mode 100644 index 000000000..18269d2f1 --- /dev/null +++ b/spec/API_specification/data_type_functions.md @@ -0,0 +1,81 @@ +# Data type functions + +> Array API specification for data type functions. + +A conforming implementation of the array API standard must provide and support the following data type functions. + + + +## Objects in API + +(finfo)= +### finfo(type, /) + +Machine limits for floating-point data types. + +#### Parameters + +- **type**: _Union\[ <dtype>, <array> ]_ + + - the kind of floating-point data-type about which to get information. + +#### Returns + +- **out**: _<class>_ + + - an object having the following attributes: + + - **bits**: _int_ + - number of bits occupied by the floating-point data type. + - **eps**: _float_ + - difference between 1.0 and the next smallest representable floating-point number larger than 1.0 according to the IEEE-754 standard. + - **max**: _float_ + - largest representable number. + - **min**: _float_ + - smallest representable number. + +(iinfo)= +### iinfo(type, /) + +Machine limits for integer data types. + +#### Parameters + +- **type**: _Union\[ <dtype>, <array> ]_ + + - the kind of integer data-type about which to get information. + +#### Returns + +- **out**: _<class>_ + + - a class with that encapsules the following attributes: + + - **bits**: _int_ + - number of bits occupied by the type + - **max**: _int_ + - largest representable number. + - **min**: _int_ + - smallest representable number. + +(function-result_type)= +### result_type(*arrays_and_dtypes) + +Returns the dtype that results from applying the type promotion rules +(see {ref}`type-promotion`) to the arguments. + +```{note} +If provided mixed dtypes (e.g., integer and floating-point), the returned dtype will be implementation-specific. +``` + +#### Parameters + +- **arrays_and_dtypes**: _Sequence\[ Union\[ <array>, <dtype> \] \];_ + + - input arrays and dtypes. + +#### Returns + +- **out**: _<dtype>_ + + - the dtype resulting from an operation involving the input arrays and dtypes. diff --git a/spec/API_specification/index.rst b/spec/API_specification/index.rst index 3d38b9c6b..55faa1c4d 100644 --- a/spec/API_specification/index.rst +++ b/spec/API_specification/index.rst @@ -11,6 +11,7 @@ API specification array_object indexing data_types + data_type_functions type_promotion broadcasting creation_functions diff --git a/spec/API_specification/utility_functions.md b/spec/API_specification/utility_functions.md index a81b709ca..aad65a71b 100644 --- a/spec/API_specification/utility_functions.md +++ b/spec/API_specification/utility_functions.md @@ -64,27 +64,3 @@ Tests whether any input array element evaluates to `True` along a specified axis - **out**: _<array>_ - 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`. - - -(function-result_type)= -### result_type(*arrays_and_dtypes) - -Returns the dtype that results from applying the type promotion rules -(see {ref}`type-promotion`) to the arguments. - -```{note} -If mixed dtypes (e.g. integer and floating-point) are used, the output of -`result_type` will be implementation-specific. -``` - -#### Parameters - -- **arrays_and_dtypes**: _Sequence\[Union\[<array>, <dtype>\]\];_ - - - input arrays and dtypes. - -#### Returns - -- **out**: _<dtype>_ - - - the dtype resulting from an operation involving the input arrays and dtypes.