Skip to content

Commit c6d5918

Browse files
authored
PR: Add finfo and iinfo in the spec (#129)
* add finfo and iinfo in the spec * move result_type function to new file and minor fixes
1 parent 2e4520a commit c6d5918

File tree

3 files changed

+82
-24
lines changed

3 files changed

+82
-24
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Data type functions
2+
3+
> Array API specification for data type functions.
4+
5+
A conforming implementation of the array API standard must provide and support the following data type functions.
6+
7+
<!-- NOTE: please keep the constants in alphabetical order -->
8+
9+
## Objects in API
10+
11+
(finfo)=
12+
### finfo(type, /)
13+
14+
Machine limits for floating-point data types.
15+
16+
#### Parameters
17+
18+
- **type**: _Union\[ &lt;dtype&gt, &lt;array&gt; ]_
19+
20+
- the kind of floating-point data-type about which to get information.
21+
22+
#### Returns
23+
24+
- **out**: _&lt;class&gt;_
25+
26+
- an object having the following attributes:
27+
28+
- **bits**: _int_
29+
- number of bits occupied by the floating-point data type.
30+
- **eps**: _float_
31+
- difference between 1.0 and the next smallest representable floating-point number larger than 1.0 according to the IEEE-754 standard.
32+
- **max**: _float_
33+
- largest representable number.
34+
- **min**: _float_
35+
- smallest representable number.
36+
37+
(iinfo)=
38+
### iinfo(type, /)
39+
40+
Machine limits for integer data types.
41+
42+
#### Parameters
43+
44+
- **type**: _Union\[ &lt;dtype&gt, &lt;array&gt; ]_
45+
46+
- the kind of integer data-type about which to get information.
47+
48+
#### Returns
49+
50+
- **out**: _&lt;class&gt;_
51+
52+
- a class with that encapsules the following attributes:
53+
54+
- **bits**: _int_
55+
- number of bits occupied by the type
56+
- **max**: _int_
57+
- largest representable number.
58+
- **min**: _int_
59+
- smallest representable number.
60+
61+
(function-result_type)=
62+
### result_type(*arrays_and_dtypes)
63+
64+
Returns the dtype that results from applying the type promotion rules
65+
(see {ref}`type-promotion`) to the arguments.
66+
67+
```{note}
68+
If provided mixed dtypes (e.g., integer and floating-point), the returned dtype will be implementation-specific.
69+
```
70+
71+
#### Parameters
72+
73+
- **arrays_and_dtypes**: _Sequence\[ Union\[ &lt;array&gt;, &lt;dtype&gt; \] \];_
74+
75+
- input arrays and dtypes.
76+
77+
#### Returns
78+
79+
- **out**: _&lt;dtype&gt;_
80+
81+
- the dtype resulting from an operation involving the input arrays and dtypes.

spec/API_specification/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ API specification
1111
array_object
1212
indexing
1313
data_types
14+
data_type_functions
1415
type_promotion
1516
broadcasting
1617
creation_functions

spec/API_specification/utility_functions.md

-24
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,3 @@ Tests whether any input array element evaluates to `True` along a specified axis
6464
- **out**: _&lt;array&gt;_
6565

6666
- 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`.
67-
68-
69-
(function-result_type)=
70-
### result_type(*arrays_and_dtypes)
71-
72-
Returns the dtype that results from applying the type promotion rules
73-
(see {ref}`type-promotion`) to the arguments.
74-
75-
```{note}
76-
If mixed dtypes (e.g. integer and floating-point) are used, the output of
77-
`result_type` will be implementation-specific.
78-
```
79-
80-
#### Parameters
81-
82-
- **arrays_and_dtypes**: _Sequence\[Union\[&lt;array&gt;, &lt;dtype&gt;\]\];_
83-
84-
- input arrays and dtypes.
85-
86-
#### Returns
87-
88-
- **out**: _&lt;dtype&gt;_
89-
90-
- the dtype resulting from an operation involving the input arrays and dtypes.

0 commit comments

Comments
 (0)