Skip to content

Commit a679857

Browse files
authored
PR: Add can-cast, broadcast-arrays and broadcast-to (#132)
1 parent f13b856 commit a679857

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

spec/API_specification/data_type_functions.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,68 @@ A conforming implementation of the array API standard must provide and support t
77
<!-- NOTE: please keep the constants in alphabetical order -->
88

99
## Objects in API
10+
(function-broadcast-arrays)=
11+
### broadcast_arrays(\*args, /)
12+
13+
Broadcasts one or more arrays against one another.
14+
15+
#### Parameters
16+
17+
- **\*args**: _Sequence\[ &lt;array&gt; ]_
18+
19+
- arrays to broadcast.
20+
21+
#### Returns
22+
23+
- **out**: _List\[ &lt;array&gt; ]_
24+
25+
- a list of broadcasted arrays. Each array must have the same shape. Each array must have the same dtype as its corresponding input array.
26+
27+
(function-broadcast-to)=
28+
### broadcast_to(x, shape, /)
29+
30+
Broadcasts an array to a specified shape.
31+
32+
#### Parameters
33+
34+
- **x**: _&lt;array&gt;_
35+
36+
- array to broadcast.
37+
38+
- **shape**: _Tuple\[int, ...]_
39+
40+
- array shape. Must be compatible with `x` (see {ref}`broadcasting`).
41+
42+
#### Returns
43+
44+
- **out**: _&lt;array&gt;_
45+
46+
- an array having a specified shape. Must have the same data type as `x`.
47+
48+
#### Raises
49+
50+
- if the array is incompatible with the specified shape (see {ref}`broadcasting`).
51+
52+
(function-can-cast)=
53+
### can_cast(from, to, /)
54+
55+
Determines if one data type can be cast to another data type according {ref}`type-promotion` rules.
56+
57+
#### Parameters
58+
59+
- **from**: _Union\[ &lt;dtype&gt;, &lt;array&gt;]_
60+
61+
- input data type or array from which to cast.
62+
63+
- **to**: _&lt;dtype&gt;_
64+
65+
- desired data type.
66+
67+
#### Returns
68+
69+
- **out**: _bool_
70+
71+
- `True` if the cast can occur according to {ref}`type-promotion` rules; otherwise, `False`.
1072

1173
(function-finfo)=
1274
### finfo(type, /)

0 commit comments

Comments
 (0)