Skip to content

Small formatting fixes to make the spec parsable by the test suite scripts #133

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 12 commits into from
Apr 11, 2021
22 changes: 16 additions & 6 deletions spec/API_specification/array_object.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ an array object supporting the following in-place Python operators:
- `+=`. May be implemented via `__iadd__`.
- `-=`. May be implemented via `__isub__`.
- `*=`. May be implemented via `__imul__`.
- `/=`. May be implemented via `__idiv__`.
- `/=`. May be implemented via `__itruediv__`.
- `//=`. May be implemented via `__ifloordiv__`.
- `**=`. May be implemented via `__ipow__`.
- `@=`. May be implemented via `__imatmul__`.
Expand All @@ -166,10 +166,10 @@ an array object supporting the following reflected operators:
- `__radd__`
- `__rsub__`
- `__rmul__`
- `__rdiv__`
- `__rfloordiv__`
- `__rtruediv__`
- `__rfloordiv__`
- `__rpow__`
- `__rmatmul__`
- `__rmod__`
- `__rand__`
- `__ror__`
Expand Down Expand Up @@ -396,12 +396,16 @@ Converts a zero-dimensional boolean array to a Python `bool` object.


(method-__dlpack__)=
### \_\_dlpack\_\_(/, *, stream=None)
### \_\_dlpack\_\_(x, /, *, stream=None)

Exports the array as a DLPack capsule, for consumption by {ref}`function-from_dlpack`.

#### Parameters

- **x**: _<array>_

- array instance.

- **stream**: _Optional\[int\]_

- An optional pointer to a stream, as a Python integer, provided by the consumer that the producer will use to make the array safe to operate on. The pointer is a positive integer. `-1` is a special value that may be used by the consumer to signal "producer must not do any synchronization". Device-specific notes:
Expand Down Expand Up @@ -439,10 +443,16 @@ Exports the array as a DLPack capsule, for consumption by {ref}`function-from_dl


(method-__dlpack_device__)=
### \_\_dlpack\_device\_\_()
### \_\_dlpack\_device\_\_(x, /)

Returns device type and device ID in DLPack format. Meant for use within {ref}`function-from_dlpack`.

#### Parameters

- **x**: _<array>_

- array instance.

#### Returns

- **device**: _Tuple\[enum.IntEnum, int\]_
Expand Down Expand Up @@ -562,7 +572,7 @@ Returns `x[key]`.

#### Parameters

- **x**: _<array;>_
- **x**: _<array>_

- array instance.

Expand Down
14 changes: 7 additions & 7 deletions spec/API_specification/data_type_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ A conforming implementation of the array API standard must provide and support t

## Objects in API

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

Machine limits for floating-point data types.

#### Parameters

- **type**: _Union\[ <dtype&gt, <array> ]_
- **type**: _Union\[ <dtype>, <array> ]_

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

#### Returns

- **out**: _<class>_
- **out**: _<finfo>_

- an object having the following attributes:

Expand All @@ -34,20 +34,20 @@ Machine limits for floating-point data types.
- **min**: _float_
- smallest representable number.

(iinfo)=
(function-iinfo)=
### iinfo(type, /)

Machine limits for integer data types.

#### Parameters

- **type**: _Union\[ <dtype&gt, <array> ]_
- **type**: _Union\[ <dtype>, <array> ]_

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

#### Returns

- **out**: _<class>_
- **out**: _<iinfo>_

- a class with that encapsules the following attributes:

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

#### Parameters

- **arrays_and_dtypes**: _Sequence\[ Union\[ <array>, <dtype> \] \];_
- **arrays_and_dtypes**: _Sequence\[ Union\[ <array>, <dtype> \] \]_

- input arrays and dtypes.

Expand Down
4 changes: 2 additions & 2 deletions spec/API_specification/elementwise_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -939,8 +939,8 @@ each element `x1_i` of the input array `x1` with the respective element `x2_i` o

For floating-point operands,

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

#### Parameters

Expand Down
7 changes: 1 addition & 6 deletions spec/API_specification/indexing.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,6 @@ Slice syntax must have the following defaults. Let `n` be the axis (dimension) s
- If `k` is greater than `0` and `j` is not provided (e.g., `0::2`), `j` must equal `n`.
- If `k` is less than `0` and `i` is not provided (e.g., `:10:-2`), `i` must equal `n-1`.
- If `k` is less than `0` and `j` is not provided (e.g., `0::-2`), `j` must equal `-n-1`.

Using a slice to index a single array axis must adhere to the following rules. Let `n` be the axis (dimension) size.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should not be removed. Otherwise, the item defined by L113 will look like it belongs to the list ending at L107.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that was also confusing to me. The two lists both seem like they are about the same thing (the behavior of a slice on an axis of size n).


- If `i` equals `j`, a slice must return an empty array, whose axis (dimension) size along the indexed axis is `0`.

- 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).

```{note}
Expand Down Expand Up @@ -184,4 +179,4 @@ The result of an indexing operation (e.g., multi-axis indexing, boolean array in
```{note}

The specified return value behavior includes indexing operations which return a single value (e.g., accessing a single element within a one-dimensional array).
```
```