Skip to content

Commit 95809a6

Browse files
authored
Replace recommonmark with MyST, fix all Sphinx issues (#72)
1 parent c0d6472 commit 95809a6

33 files changed

+567
-502
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
sphinx==3.1.1
22
sphinx-material==0.0.30
3-
recommonmark
3+
myst-parser
44
sphinx_markdown_tables
55
sphinx_copybutton

spec/API_specification/array_object.md

Lines changed: 156 additions & 132 deletions
Large diffs are not rendered by default.

spec/API_specification/broadcasting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. _broadcasting:
1+
(broadcasting)=
22

33
# Broadcasting
44

spec/API_specification/casting.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

spec/API_specification/constants.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ A conforming implementation of the array API standard must provide and support t
66

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

9+
## Objects in API
10+
911
### <a name="e" href="#e">#</a> e
1012

1113
Euler's constant.

spec/API_specification/creation_functions.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ A conforming implementation of the array API standard must provide and support t
77
- Positional parameters must be [positional-only](https://www.python.org/dev/peps/pep-0570/) parameters. Positional-only parameters have no externally-usable name. When a function accepting positional-only parameters is called, positional arguments are mapped to these parameters based solely on their order.
88
- Optional parameters must be [keyword-only](https://www.python.org/dev/peps/pep-3102/) arguments.
99

10+
## Objects in API
11+
1012
<!-- NOTE: please keep the functions in alphabetical order -->
1113

1214
### <a name="arange" href="#arange">#</a> arange(start, /, *, stop=None, step=1, dtype=None)
@@ -23,9 +25,10 @@ Returns evenly spaced values within the half-open interval `[start, stop)` as a
2325

2426
- the end of the interval. Default: `None`.
2527

26-
.. note::
28+
```{note}
2729
28-
This function cannot guarantee that the interval does not include the `stop` value in those cases where `step` is not an integer and floating-point rounding errors affect the length of the output array.
30+
This function cannot guarantee that the interval does not include the `stop` value in those cases where `step` is not an integer and floating-point rounding errors affect the length of the output array.
31+
```
2932

3033
- **step**: _Union\[ int, float ]_
3134

spec/API_specification/data_types.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
1-
.. _data-types:
1+
(data-types)=
22

33
# Data Types
44

55
> Array API specification for supported data types.
66
77
A conforming implementation of the array API standard must provide and support the following data types.
88

9-
.. note::
9+
```{note}
1010
11-
Data types ("dtypes") are objects that can be used as `dtype` specifiers in functions and methods (e.g., `zeros((2, 3), dtype=float32)`). A conforming implementation may add methods or attributes to data type objects; however, these methods and attributes are not included in this specification.
11+
Data types ("dtypes") are objects that can be used as `dtype` specifiers in functions and methods (e.g., `zeros((2, 3), dtype=float32)`). A conforming implementation may add methods or attributes to data type objects; however, these methods and attributes are not included in this specification.
12+
```
1213

13-
.. note::
14+
```{note}
1415
15-
Implementations may provide other ways to specify data types (e.g.,
16-
`zeros((2, 3), dtype='f4')`); however, these are not included in this specification.
16+
Implementations may provide other ways to specify data types (e.g.,
17+
`zeros((2, 3), dtype='f4')`); however, these are not included in this specification.
18+
```
1719

1820
A conforming implementation of the array API standard may provide and support additional data types beyond those described in this specification.
1921

2022
A conforming implementation of the array API standard must define a default floating-point data type (either `float32` or `float64`).
2123

22-
.. note::
24+
```{note}
2325
24-
The default floating-point data type should be clearly defined in a conforming library's documentation.
26+
The default floating-point data type should be clearly defined in a conforming library's documentation.
27+
```
2528

2629
A conforming implementation of the array API standard must define a default data type for an array index (either `int32` or `int64`).
2730

28-
.. note::
31+
```{note}
2932
30-
The default array index data type should be clearly defined in a conforming library's documentation.
33+
The default array index data type should be clearly defined in a conforming library's documentation.
34+
```
3135

3236

3337
## bool

spec/API_specification/elementwise_functions.md

Lines changed: 132 additions & 125 deletions
Large diffs are not rendered by default.

spec/API_specification/function_and_method_signatures.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. _function-and-method-signatures:
1+
(function-and-method-signatures)=
22

33
# Function and method signatures
44

@@ -13,12 +13,13 @@ Function signatures in this standard adhere to the following:
1313
_Rationale: existing libraries have incompatible conventions, and using names
1414
of positional parameters is not normal/recommended practice._
1515

16-
.. note::
16+
```{note}
1717
18-
Positional-only parameters are only available in Python >= 3.8. Libraries
19-
still supporting 3.7 or 3.6 may consider making the API standard-compliant
20-
namespace >= 3.8. Alternatively, they can add guidance to their users in the
21-
documentation to use the functions as if they were positional-only.
18+
Positional-only parameters are only available in Python >= 3.8. Libraries
19+
still supporting 3.7 or 3.6 may consider making the API standard-compliant
20+
namespace >= 3.8. Alternatively, they can add guidance to their users in the
21+
documentation to use the functions as if they were positional-only.
22+
```
2223
2324
2. Optional parameters must be
2425
[keyword-only](https://www.python.org/dev/peps/pep-3102/) arguments.

spec/API_specification/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ API specification
1212
indexing
1313
data_types
1414
type_promotion
15-
casting
1615
broadcasting
1716
creation_functions
1817
manipulation_functions

spec/API_specification/indexing.md

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. _indexing:
1+
(indexing)=
22

33
# Indexing
44

@@ -16,21 +16,24 @@ To index a single array axis, an array must support standard Python indexing rul
1616

1717
- **Valid** nonnegative indices must reside on the half-open interval `[0, n)`.
1818

19-
.. note::
19+
```{note}
2020
21-
This specification does not require bounds checking. The behavior for out-of-bounds integer indices is left unspecified.
21+
This specification does not require bounds checking. The behavior for out-of-bounds integer indices is left unspecified.
22+
```
2223
2324
- Negative indices must count backward from the last array index, starting from `-1` (i.e., negative-one-based indexing, where `-1` refers to the last array index).
2425
25-
.. note::
26+
```{note}
2627
27-
A negative index `j` is equivalent to `n-j`; the former is syntactic sugar for the latter, providing a shorthand for indexing elements that would otherwise need to be specified in terms of the axis (dimension) size.
28+
A negative index `j` is equivalent to `n-j`; the former is syntactic sugar for the latter, providing a shorthand for indexing elements that would otherwise need to be specified in terms of the axis (dimension) size.
29+
```
2830
2931
- **Valid** negative indices must reside on the closed interval `[-n, -1]`.
3032
31-
.. note::
33+
```{note}
3234
33-
This specification does not require bounds checking. The behavior for out-of-bounds integer indices is left unspecified.
35+
This specification does not require bounds checking. The behavior for out-of-bounds integer indices is left unspecified.
36+
```
3437
3538
- A negative index `j` is related to a zero-based nonnegative index `i` via `i = n+j`.
3639
@@ -56,9 +59,10 @@ A[i::k]
5659
A[i:j:k]
5760
```
5861

59-
.. note::
62+
```{note}
6063
61-
Slice syntax can be equivalently achieved using the Python built-in [`slice()`](https://docs.python.org/3/library/functions.html#slice) API. From the perspective from `A`, the behavior of `A[i:j:k]` and `A[slice(i, j, k)]` is indistinguishable (i.e., both retrieve the same set of items from `__getitem__`).
64+
Slice syntax can be equivalently achieved using the Python built-in [`slice()`](https://docs.python.org/3/library/functions.html#slice) API. From the perspective from `A`, the behavior of `A[i:j:k]` and `A[slice(i, j, k)]` is indistinguishable (i.e., both retrieve the same set of items from `__getitem__`).
65+
```
6266

6367
Using a slice to index a single array axis must select `m` elements with index values
6468

@@ -84,13 +88,15 @@ such that
8488
j > i + (m-1)k
8589
```
8690

87-
.. note::
91+
```{note}
8892
89-
For `i` on the interval `[0, n)` (where `n` is the axis size), `j` on the interval `(0, n]`, `i` less than `j`, and positive step `k`, a starting index `i` is **always** included, while the stopping index `j` is **always** excluded. This preserves `x[:i]+x[i:]` always being equal to `x`.
93+
For `i` on the interval `[0, n)` (where `n` is the axis size), `j` on the interval `(0, n]`, `i` less than `j`, and positive step `k`, a starting index `i` is **always** included, while the stopping index `j` is **always** excluded. This preserves `x[:i]+x[i:]` always being equal to `x`.
94+
```
9095

91-
.. note::
96+
```{note}
9297
93-
Using a slice to index into a single array axis should select the same elements as using a slice to index a Python list of the same size.
98+
Using a slice to index into a single array axis should select the same elements as using a slice to index a Python list of the same size.
99+
```
94100

95101
Slice syntax must have the following defaults. Let `n` be the axis (dimension) size.
96102

@@ -106,27 +112,30 @@ Using a slice to index a single array axis must adhere to the following rules. L
106112

107113
- Indexing via `:` and `::` must be equivalent and have defaults derived from the rules above. Both `:` and `::` indicate to select all elements along a single axis (dimension).
108114

109-
.. note::
115+
```{note}
110116
111-
This specification does not require "clipping" out-of-bounds indices (i.e., requiring the starting and stopping indices `i` and `j` be bound by `0` and `n`, respectively).
117+
This specification does not require "clipping" out-of-bounds indices (i.e., requiring the starting and stopping indices `i` and `j` be bound by `0` and `n`, respectively).
112118
113-
_Rationale: this is consistent with bounds checking for integer indexing; the behavior of out-of-bounds indices is left unspecified. Implementations may choose to clip, raise an exception, return junk values, or some other behavior depending on device requirements and performance considerations._
119+
_Rationale: this is consistent with bounds checking for integer indexing; the behavior of out-of-bounds indices is left unspecified. Implementations may choose to clip, raise an exception, return junk values, or some other behavior depending on device requirements and performance considerations._
120+
```
114121

115-
.. note::
122+
```{note}
116123
117-
This specification leaves unspecified the behavior of indexing a single array axis with an out-of-bounds slice (i.e., a slice which does not select any array axis elements).
124+
This specification leaves unspecified the behavior of indexing a single array axis with an out-of-bounds slice (i.e., a slice which does not select any array axis elements).
118125
119-
_Rationale: this is consistent with bounds checking for integer indexing; the behavior of out-of-bounds indices is left unspecified. Implementations may choose to return an empty array (whose axis (dimension) size along the indexed axis is `0`), raise an exception, or some other behavior depending on device requirements and performance considerations._
126+
_Rationale: this is consistent with bounds checking for integer indexing; the behavior of out-of-bounds indices is left unspecified. Implementations may choose to return an empty array (whose axis (dimension) size along the indexed axis is `0`), raise an exception, or some other behavior depending on device requirements and performance considerations._
127+
```
120128

121129
## Multi-axis Indexing
122130

123131
Multi-dimensional arrays must extend the concept of single-axis indexing to multiple axes by applying single-axis indexing rules along each axis (dimension) and supporting the following additional rules. Let `N` be the number of dimensions ("rank") of a multi-dimensional array `A`.
124132

125133
- Each axis may be independently indexed via single-axis indexing by providing a comma-separated sequence ("selection tuple") of single-axis indexing expressions (e.g., `A[:, 2:10, :, 5]`).
126134

127-
.. note::
135+
```{note}
128136
129-
In Python, `x[(exp1, exp2, ..., expN)]` is equivalent to `x[exp1, exp2, ..., expN]`; the latter is syntactic sugar for the former.
137+
In Python, `x[(exp1, exp2, ..., expN)]` is equivalent to `x[exp1, exp2, ..., expN]`; the latter is syntactic sugar for the former.
138+
```
130139
131140
- Providing a single nonnegative integer `i` as a single-axis index must index the same elements as the slice `i:i+1`.
132141
@@ -144,21 +153,23 @@ Multi-dimensional arrays must extend the concept of single-axis indexing to mult
144153
145154
- The result of multi-axis indexing must be an array of the same data type as the indexed array.
146155
147-
.. note::
156+
```{note}
148157
149-
This specification leaves unspecified the behavior of providing a slice which attempts to select elements along a particular axis, but whose starting index is out-of-bounds.
158+
This specification leaves unspecified the behavior of providing a slice which attempts to select elements along a particular axis, but whose starting index is out-of-bounds.
150159
151-
_Rationale: this is consistent with bounds-checking for single-axis indexing. An implementation may choose to set the axis (dimension) size of the result array to `0`, raise an exception, return junk values, or some other behavior depending on device requirements and performance considerations._
160+
_Rationale: this is consistent with bounds-checking for single-axis indexing. An implementation may choose to set the axis (dimension) size of the result array to `0`, raise an exception, return junk values, or some other behavior depending on device requirements and performance considerations._
161+
```
152162

153163
## Boolean Array Indexing
154164

155165
An array must support indexing via a **single** `M`-dimensional boolean array `B` with shape `S1 = (s1, ..., sM)` according to the following rules. Let `A` be an `N`-dimensional array with shape `S2 = (s1, ..., sM, ..., sN)`.
156166

157167
- If `N >= M`, then `A[B]` must replace the first `M` dimensions of `A` with a single dimension having a size equal to the number of `True` elements in `B`. The values in the resulting array must be in row-major (C-style order); this is equivalent to `A[nonzero(B)]`.
158168

159-
.. note::
169+
```{note}
160170
161-
For example, if `N == M == 2`, indexing `A` via a boolean array `B` will return a one-dimensional array whose size is equal to the number of `True` elements in `B`.
171+
For example, if `N == M == 2`, indexing `A` via a boolean array `B` will return a one-dimensional array whose size is equal to the number of `True` elements in `B`.
172+
```
162173
163174
- If `N < M`, then an `IndexError` exception must be raised.
164175

spec/API_specification/linear_algebra_functions.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ A conforming implementation of the array API standard must provide and support t
66

77
- Positional parameters must be [positional-only](https://www.python.org/dev/peps/pep-0570/) parameters. Positional-only parameters have no externally-usable name. When a function accepting positional-only parameters is called, positional arguments are mapped to these parameters based solely on their order.
88
- Optional parameters must be [keyword-only](https://www.python.org/dev/peps/pep-3102/) arguments.
9-
- Broadcasting semantics must follow the semantics defined in :ref:`broadcasting`.
10-
- Unless stated otherwise, functions must support the data types defined in :ref:`data-types`.
11-
- Unless stated otherwise, functions must adhere to the type promotion rules defined in :ref:`type-promotion`.
9+
- Broadcasting semantics must follow the semantics defined in {ref}`broadcasting`.
10+
- Unless stated otherwise, functions must support the data types defined in {ref}`data-types`.
11+
- Unless stated otherwise, functions must adhere to the type promotion rules defined in {ref}`type-promotion`.
1212
- Unless stated otherwise, floating-point operations must adhere to IEEE 754-2019.
1313

14+
## Objects in API
15+
1416
<!-- NOTE: please keep the functions in alphabetical order -->
1517

1618
### <a name="cholesky" href="#cholesky">#</a> cholesky()
@@ -39,7 +41,7 @@ Returns the cross product of 3-element vectors. If `x1` and `x2` are multi-dimen
3941

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

42-
- an array containing the cross products. The returned array must have a data type determined by :ref:`type-promotion` rules.
44+
- an array containing the cross products. The returned array must have a data type determined by {ref}`type-promotion` rules.
4345

4446
### <a name="det" href="#det">#</a> det(x, /)
4547

@@ -55,7 +57,7 @@ Returns the determinant of a square matrix (or stack of square matrices) `x`.
5557

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

58-
- if `x` is a two-dimensional array, a zero-dimensional array containing the determinant; otherwise, a non-zero dimensional array containing the determinant for each square matrix. The returned array must have a data type determined by :ref:`type-promotion` rules.
60+
- if `x` is a two-dimensional array, a zero-dimensional array containing the determinant; otherwise, a non-zero dimensional array containing the determinant for each square matrix. The returned array must have a data type determined by {ref}`type-promotion` rules.
5961

6062
### <a name="diagonal" href="#diagonal">#</a> diagonal(x, /, *, axis1=0, axis2=1, offset=0)
6163

@@ -165,7 +167,7 @@ Computes the matrix or vector norm of `x`.
165167

166168
- **keepdims**: _bool_
167169

168-
- If `True`, the axes (dimensions) specified by `axis` must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see :ref:`broadcasting`). Otherwise, if `False`, the axes (dimensions) specified by `axis` must not be included in the result. Default: `False`.
170+
- If `True`, the axes (dimensions) specified by `axis` must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see {ref}`broadcasting`). Otherwise, if `False`, the axes (dimensions) specified by `axis` must not be included in the result. Default: `False`.
169171

170172
- **ord**: _Optional\[ int, float, Literal\[ inf, -inf, 'fro', 'nuc' ] ]_
171173

@@ -235,7 +237,7 @@ Computes the outer product of two vectors `x1` and `x2`.
235237

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

238-
- a two-dimensional array containing the outer product and whose shape is `NxM`. The returned array must have a data type determined by :ref:`type-promotion` rules.
240+
- a two-dimensional array containing the outer product and whose shape is `NxM`. The returned array must have a data type determined by {ref}`type-promotion` rules.
239241

240242
### <a name="pinv" href="#pinv">#</a> pinv()
241243

0 commit comments

Comments
 (0)