Skip to content

PR: Add finfo and iinfo in the spec #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions spec/API_specification/data_type_functions.md
Original file line number Diff line number Diff line change
@@ -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.

<!-- NOTE: please keep the constants in alphabetical order -->

## Objects in API

(finfo)=
### finfo(type, /)

Machine limits for floating-point data types.

#### Parameters

- **type**: _Union\[ &lt;dtype&gt, &lt;array&gt; ]_

- the kind of floating-point data-type about which to get information.

#### Returns

- **out**: _&lt;class&gt;_

- 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\[ &lt;dtype&gt, &lt;array&gt; ]_

- the kind of integer data-type about which to get information.

#### Returns

- **out**: _&lt;class&gt;_

- 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\[ &lt;array&gt;, &lt;dtype&gt; \] \];_

- input arrays and dtypes.

#### Returns

- **out**: _&lt;dtype&gt;_

- the dtype resulting from an operation involving the input arrays and dtypes.
1 change: 1 addition & 0 deletions spec/API_specification/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ API specification
array_object
indexing
data_types
data_type_functions
type_promotion
broadcasting
creation_functions
Expand Down
24 changes: 0 additions & 24 deletions spec/API_specification/utility_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,3 @@ Tests whether any input array element evaluates to `True` along a specified axis
- **out**: _&lt;array&gt;_

- 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\[&lt;array&gt;, &lt;dtype&gt;\]\];_

- input arrays and dtypes.

#### Returns

- **out**: _&lt;dtype&gt;_

- the dtype resulting from an operation involving the input arrays and dtypes.