Skip to content

Commit f13b856

Browse files
asmeurerrgommers
andauthored
Small formatting fixes to make the spec parsable by the test suite scripts (data-apis#133)
* Small formatting fixes to make the spec parsable by the test suite scripts * More formatting fixes * Fix in-place and reflected operator consistency __div__ is a relic from Python 2. It no longer does anything in Python 3. The reflected operators were missing __rmatmul__. Now they completely match the in-place operators. * Add self arguments for __dlpack__ and __dlpack_device__ * Make x positional only in __dlpack__() * Remove an inconsistent rule about indexing The rule said that empty slices should work, but the note right below that says that they are optional. * Revert "Remove an inconsistent rule about indexing" This reverts commit d9d51aa. * Clarify that Python integer overflow behavior is undefined * One more x -> self update Co-authored-by: Ralf Gommers <[email protected]>
1 parent 15889c6 commit f13b856

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

spec/API_specification/array_object.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ an array object supporting the following in-place Python operators:
142142
- `+=`. May be implemented via `__iadd__`.
143143
- `-=`. May be implemented via `__isub__`.
144144
- `*=`. May be implemented via `__imul__`.
145-
- `/=`. May be implemented via `__idiv__`.
145+
- `/=`. May be implemented via `__itruediv__`.
146146
- `//=`. May be implemented via `__ifloordiv__`.
147147
- `**=`. May be implemented via `__ipow__`.
148148
- `@=`. May be implemented via `__imatmul__`.
@@ -166,10 +166,10 @@ an array object supporting the following reflected operators:
166166
- `__radd__`
167167
- `__rsub__`
168168
- `__rmul__`
169-
- `__rdiv__`
170-
- `__rfloordiv__`
171169
- `__rtruediv__`
170+
- `__rfloordiv__`
172171
- `__rpow__`
172+
- `__rmatmul__`
173173
- `__rmod__`
174174
- `__rand__`
175175
- `__ror__`
@@ -425,6 +425,10 @@ Exports the array for consumption by {ref}`function-from_dlpack` as a DLPack cap
425425

426426
#### Parameters
427427

428+
- **self**: _&lt;array&gt;_
429+
430+
- array instance.
431+
428432
- **stream**: _Optional\[ int ]_
429433

430434
- a Python integer representing a pointer to a stream. `stream` is provided by the consumer to the producer to instruct the producer to ensure that operations can safely be performed on the array. The pointer must be a positive integer or `-1`. If `stream` is `-1`, the value may be used by the consumer to signal "producer must not perform any synchronization". Device-specific notes:
@@ -462,10 +466,16 @@ Exports the array for consumption by {ref}`function-from_dlpack` as a DLPack cap
462466
463467
464468
(method-__dlpack_device__)=
465-
### \_\_dlpack\_device\_\_()
469+
### \_\_dlpack\_device\_\_(self, /)
466470
467471
Returns device type and device ID in DLPack format. Meant for use within {ref}`function-from_dlpack`.
468472
473+
#### Parameters
474+
475+
- **self**: _&lt;array&gt;_
476+
477+
- array instance.
478+
469479
#### Returns
470480
471481
- **device**: _Tuple\[enum.IntEnum, int\]_

spec/API_specification/data_type_functions.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ A conforming implementation of the array API standard must provide and support t
88

99
## Objects in API
1010

11-
(finfo)=
11+
(function-finfo)=
1212
### finfo(type, /)
1313

1414
Machine limits for floating-point data types.
1515

1616
#### Parameters
1717

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

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

@@ -34,14 +34,14 @@ Machine limits for floating-point data types.
3434
- **min**: _float_
3535
- smallest representable number.
3636

37-
(iinfo)=
37+
(function-iinfo)=
3838
### iinfo(type, /)
3939

4040
Machine limits for integer data types.
4141

4242
#### Parameters
4343

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

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

@@ -70,7 +70,7 @@ If provided mixed dtypes (e.g., integer and floating-point), the returned dtype
7070

7171
#### Parameters
7272

73-
- **arrays_and_dtypes**: _Sequence\[ Union\[ &lt;array&gt;, &lt;dtype&gt; \] \];_
73+
- **arrays_and_dtypes**: _Sequence\[ Union\[ &lt;array&gt;, &lt;dtype&gt; \] \]_
7474

7575
- input arrays and dtypes.
7676

spec/API_specification/elementwise_functions.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -939,8 +939,8 @@ each element `x1_i` of the input array `x1` with the respective element `x2_i` o
939939

940940
For floating-point operands,
941941

942-
- If `x1_i` or `x2_i` is `NaN`, the result is `NaN`.
943-
- If `x1_i` or `x2_i` is `+infinity`, the result is `+infinity`.
942+
- If either `x1_i` or `x2_i` is `NaN`, the result is `NaN`.
943+
- If either `x1_i` or `x2_i` is `+infinity`, the result is `+infinity`.
944944

945945
#### Parameters
946946

spec/API_specification/type_promotion.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ diagram:
99

1010
![Type promotion diagram](/_static/images/dtype_promotion_lattice.png)
1111

12-
_Type promotion diagram. Promotion between any two types is given by their join on this lattice. Only the types of participating arrays matter, not their values). Dashed lines indicate that behaviour for Python scalars is undefined on overflow. Boolean, integer and floating-point dtypes are not connected, indicating mixed-kind promotion is undefined._
12+
_Type promotion diagram. Promotion between any two types is given by their join on this lattice. Only the types of participating arrays matter, not their values. Dashed lines indicate that behavior for Python scalars is undefined on overflow. Boolean, integer and floating-point dtypes are not connected, indicating mixed-kind promotion is undefined._
1313

1414

1515
## Rules
@@ -106,8 +106,7 @@ where `<op>` is a built-in operator (see {ref}`operators` for operators
106106
supported by the array object) and `scalar` has a compatible type and value
107107
to the array dtype:
108108
- Python `bool` for a `bool` array dtype,
109-
- a positive Python `int` for unsigned integer array dtypes,
110-
- a Python `int` for integer array dtypes,
109+
- a Python `int` within the [bounds](data-types) of the given dtype for integer array dtypes,
111110
- a Python `int` or `float` for floating-point array dtypes
112111
The expected behavior is then equivalent to:
113112

@@ -121,4 +120,7 @@ The expected behavior is then equivalent to:
121120
Behaviour is not specified when mixing a Python `float` and an array with an
122121
integer dtype; this may give `float32`, `float64`, or raise an exception -
123122
behavior of implementations will differ.
123+
124+
The behavior is also not specified for integers outside of the bounds of a
125+
given integer dtype. It may overflow, or result in an error.
124126
```

0 commit comments

Comments
 (0)