You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update API specification for creation and manipulation functions (#167)
* Update specification for arange
Addresses comments in gh-85 and gh-107
* Update the specification for `full` and `full_like`
Addresses comments in gh-85 and gh-107
* Update specification for `linspace`
Addresses comments in gh-85 and gh-107
* Update specification for `empty`, `ones`, `zeros`
Addresses comments in gh-85 and gh-107
* Update specification for `eye`
This is useful/needed because `M` is not a descriptive name
and that name does not match between different array libraries.
* Update specification for `expand_dims`, `roll` and `reshape`
Address comment in gh-85
* One more change to `eye`, more descriptive positional arguments
* Address the default integer dtype issue for 32/64-bit Python
Closesgh-151
* Update signature of `broadcast_to`
Address a review comment; makes it consistent with other functions
using `shape`.
Returns evenly spaced values within the half-open interval `[start, stop)` as a one-dimensional array.
18
18
@@ -33,11 +33,11 @@ This function cannot guarantee that the interval does not include the `stop` val
33
33
34
34
-**step**: _Union\[ int, float ]_
35
35
36
-
- the distance between two adjacent elements (`out[i+1] - out[i]`). Default: `1`.
36
+
- the distance between two adjacent elements (`out[i+1] - out[i]`). Must not be `0`; may be negative, this results in an empty array if `stop >= start`. Default: `1`.
37
37
38
38
-**dtype**: _Optional\[<dtype>]_
39
39
40
-
- output array data type. If `dtype` is `None`, the output array data type must be the default floating-point data type. Default: `None`.
40
+
- output array data type. If `dtype` is `None`, the output array data type must be inferred from `start`, `stop` and `step`. If those are all integers, the output array dtype must be the default integer dtype; if one or more have type `float`, then the output array dtype must be the default floating-point data type. Default: `None`.
41
41
42
42
-**device**: _Optional\[<device>]_
43
43
@@ -47,7 +47,7 @@ This function cannot guarantee that the interval does not include the `stop` val
47
47
48
48
-**out**: _<array>_
49
49
50
-
- a one-dimensional array containing evenly spaced values. The length of the output array must be `ceil((stop-start)/step)`.
50
+
- a one-dimensional array containing evenly spaced values. The length of the output array must be `ceil((stop-start)/step)` if `stop - start` and `step` have the same sign, and length 0 otherwise.
51
51
52
52
53
53
(function-asarray)=
@@ -68,7 +68,7 @@ Convert the input to an array.
68
68
69
69
-**dtype**: _Optional\[<dtype>]_
70
70
71
-
- output array data type. If `dtype` is `None`, the output array data type must be inferred from the data type(s) in `obj`. Default: `None`.
71
+
- output array data type. If `dtype` is `None`, the output array data type must be inferred from the data type(s) in `obj`. If all input values are Python scalars, then if they're all `bool` the output dtype will be `bool`; if they're a mix of `bool`s and `int` the output dtype will be the default integer data type; if they contain `float`s the output dtype will be the default floating-point data type. Default: `None`.
72
72
73
73
-**device**: _Optional\[<device>]_
74
74
@@ -86,7 +86,7 @@ Convert the input to an array.
86
86
87
87
88
88
(function-empty)=
89
-
### empty(shape, /, *, dtype=None, device=None)
89
+
### empty(shape, *, dtype=None, device=None)
90
90
91
91
Returns an uninitialized array having a specified `shape`.
92
92
@@ -136,19 +136,19 @@ Returns an uninitialized array with the same `shape` as an input array `x`.
136
136
- an array having the same shape as `x` and containing uninitialized data.
Returns a new array having a specified `shape` and filled with `fill_value`.
196
196
@@ -206,7 +206,7 @@ Returns a new array having a specified `shape` and filled with `fill_value`.
206
206
207
207
- **dtype**: _Optional\[ <dtype> ]_
208
208
209
-
- output array data type. If `dtype` is `None`, the output array data type must be the default floating-point data type. Default: `None`.
209
+
- output array data type. If `dtype` is `None`, the output array data type must be inferred from `fill_value`. If it's an `int`, the output array dtype must be the default integer dtype; if it's a `float`, then the output array dtype must be the default floating-point data type; if it's a `bool` then the output array must have boolean dtype. Default: `None`.
210
210
211
211
- **device**: _Optional\[ <device> ]_
212
212
@@ -219,7 +219,7 @@ Returns a new array having a specified `shape` and filled with `fill_value`.
219
219
- an array where every element is equal to `fill_value`.
Returns a new array filled with `fill_value` and having the same `shape` as an input array `x`.
225
225
@@ -235,7 +235,7 @@ Returns a new array filled with `fill_value` and having the same `shape` as an i
235
235
236
236
- **dtype**: _Optional\[ <dtype> ]_
237
237
238
-
- output array data type. If `dtype` is `None`, the output array data type must be inferred from `x`. Default: `None`.
238
+
- output array data type. If `dtype` is `None`, the output array data type must be inferred from `fill_value` (see {ref}`function-full`). Default: `None`.
239
239
240
240
- **device**: _Optional\[ <device> ]_
241
241
@@ -248,7 +248,7 @@ Returns a new array filled with `fill_value` and having the same `shape` as an i
248
248
- an array having the same shape as `x` and where every element is equal to `fill_value`.
Copy file name to clipboardExpand all lines: spec/API_specification/data_types.md
+1-2Lines changed: 1 addition & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -6,10 +6,9 @@
6
6
7
7
A conforming implementation of the array API standard must provide and support the following data types.
8
8
9
-
A conforming implementation of the array API standard must define a default floating-point data type (either `float32` or `float64`), as well as a default data type for an array index (either `int32` or `int64`).
9
+
A conforming implementation of the array API standard must define a default floating-point data type (either `float32` or `float64`), as well as a default integer data type (`int32` or `int64`). These default data types must be the same across platforms. The default integer data type may vary depending on whether Python is 32-bit or 64-bit.
10
10
11
11
```{note}
12
-
13
12
The default floating-point and array index integer data types should be clearly defined in a conforming library's documentation.
Copy file name to clipboardExpand all lines: spec/API_specification/manipulation_functions.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ Joins a sequence of arrays along an existing axis.
39
39
```
40
40
41
41
(function-expand_dims)=
42
-
### expand_dims(x, axis, /)
42
+
### expand_dims(x, /, *, axis)
43
43
44
44
Expands the shape of an array by inserting a new axis (dimension) of size one at the position specified by `axis`.
45
45
@@ -81,7 +81,7 @@ Reverses the order of elements in an array along the given axis. The shape of th
81
81
- an output array having the same data type and shape as `x` and whose elements, relative to `x`, are reordered.
82
82
83
83
(function-reshape)=
84
-
### reshape(x, shape, /)
84
+
### reshape(x, /, shape)
85
85
86
86
Reshapes an array without changing its data.
87
87
@@ -102,7 +102,7 @@ Reshapes an array without changing its data.
102
102
- an output array having the same data type, elements, and underlying element order as `x`.
103
103
104
104
(function-roll)=
105
-
### roll(x, shift, /, *, axis=None)
105
+
### roll(x, /, shift, *, axis=None)
106
106
107
107
Rolls array elements along a specified axis. Array elements that roll beyond the last position are re-introduced at the first position. Array elements that roll beyond the first position are re-introduced at the last position.
0 commit comments