Skip to content

PR: Add can-cast, broadcast-arrays and broadcast-to #132

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 11 commits into from
Apr 19, 2021
62 changes: 62 additions & 0 deletions spec/API_specification/data_type_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,68 @@ A conforming implementation of the array API standard must provide and support t
<!-- NOTE: please keep the constants in alphabetical order -->

## Objects in API
(function-broadcast-arrays)=
### broadcast_arrays(\*args, /)

Broadcasts one or more arrays against one another.

#### Parameters

- **\*args**: _Sequence\[ &lt;array&gt; ]_

- arrays to broadcast.

#### Returns

- **out**: _List\[ &lt;array&gt; ]_

- a list of broadcasted arrays. Each array must have the same shape. Each array must have the same dtype as its corresponding input array.

(function-broadcast-to)=
### broadcast_to(x, shape, /)

Broadcasts an array to a specified shape.

#### Parameters

- **x**: _&lt;array&gt;_

- array to broadcast.

- **shape**: _Tuple\[int, ...]_

- array shape. Must be compatible with `x` (see {ref}`broadcasting`).

#### Returns

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

- an array having a specified shape. Must have the same data type as `x`.

#### Raises

- if the array is incompatible with the specified shape (see {ref}`broadcasting`).

(function-can-cast)=
### can_cast(from, to, /)

Determines if one data type can be cast to another data type according {ref}`type-promotion` rules.

#### Parameters

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

- input data type or array from which to cast.

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

- desired data type.

#### Returns

- **out**: _bool_

- `True` if the cast can occur according to {ref}`type-promotion` rules; otherwise, `False`.

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