Skip to content

Commit 35671a4

Browse files
honnokgryte
andauthored
Clarify that the results of division operations on integer array data types resulting in floating-point outputs is implementation-defined (#362)
* Make int inputs for divide functions out-of-scope * Clarify mixed kind promotion is unspecified for divide notes * Clearer language for noting mixed kind promotion * Prohibit div functions return int arrays Also fixes related note wording for `min()` and `max()` * Better legibility of mixed kinds note Co-authored-by: Athan <[email protected]> Co-authored-by: Athan <[email protected]>
1 parent dec7fef commit 35671a4

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

spec/API_specification/array_object.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ Calculates an implementation-dependent approximation of exponentiation by raisin
11151115
```{note}
11161116
If both `self` and `other` have integer data types, the result of `__pow__` when `other_i` is negative (i.e., less than zero) is unspecified and thus implementation-dependent.
11171117
1118-
If `self` has an integer data type and `other` has a floating-point data type, behavior is implementation-dependent (type promotion between data type "kinds" (integer versus floating-point) is unspecified).
1118+
If `self` has an integer data type and `other` has a floating-point data type, behavior is implementation-dependent, as type promotion between data type "kinds" (e.g., integer versus floating-point) is unspecified.
11191119
```
11201120

11211121
#### Special Cases
@@ -1249,6 +1249,12 @@ Element-wise results must equal the results returned by the equivalent element-w
12491249

12501250
Evaluates `self_i / other_i` for each element of an array instance with the respective element of the array `other`.
12511251

1252+
```{note}
1253+
If one or both of `self` and `other` have integer data types, the result is implementation-dependent, as type promotion between data type "kinds" (e.g., integer versus floating-point) is unspecified.
1254+
1255+
Specification-compliant libraries may choose to raise an error or return an array containing the element-wise results. If an array is returned, the array must have a floating-point data type.
1256+
```
1257+
12521258
#### Special Cases
12531259

12541260
For floating-point operands, let `self` equal `x1` and `other` equal `x2`.

spec/API_specification/elementwise_functions.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,12 @@ For floating-point operands,
528528

529529
Calculates the division for each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`.
530530

531+
```{note}
532+
If one or both of the input arrays have integer data types, the result is implementation-dependent, as type promotion between data type "kinds" (e.g., integer versus floating-point) is unspecified.
533+
534+
Specification-compliant libraries may choose to raise an error or return an array containing the element-wise results. If an array is returned, the array must have a floating-point data type.
535+
```
536+
531537
#### Special Cases
532538

533539
For floating-point operands,
@@ -1223,7 +1229,7 @@ Calculates an implementation-dependent approximation of exponentiation by raisin
12231229
```{note}
12241230
If both `x1` and `x2` have integer data types, the result of `pow` when `x2_i` is negative (i.e., less than zero) is unspecified and thus implementation-dependent.
12251231
1226-
If `x1` has an integer data type and `x2` has a floating-point data type, behavior is implementation-dependent (type promotion between data type "kinds" (integer versus floating-point) is unspecified).
1232+
If `x1` has an integer data type and `x2` has a floating-point data type, behavior is implementation-dependent, as type promotion between data type "kinds" (e.g., integer versus floating-point) is unspecified.
12271233
```
12281234

12291235
#### Special Cases

spec/API_specification/statistical_functions.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ A conforming implementation of the array API standard must provide and support t
2121
Calculates the maximum value of the input array `x`.
2222

2323
```{note}
24-
When the number of elements over which to compute the maximum value is zero, the maximum value is implementation-defined. Specification-compliant libraries may choose to error, return a sentinel value (e.g., if `x` is a floating-point input array, return `NaN`), or return the minimum possible value for the input array `x` data type (e.g., if `x` is a floating-point array, return `-infinity`).
24+
When the number of elements over which to compute the maximum value is zero, the maximum value is implementation-defined. Specification-compliant libraries may choose to raise an error, return a sentinel value (e.g., if `x` is a floating-point input array, return `NaN`), or return the minimum possible value for the input array `x` data type (e.g., if `x` is a floating-point array, return `-infinity`).
2525
```
2626

2727
#### Special Cases
@@ -92,7 +92,7 @@ Let `N` equal the number of elements over which to compute the arithmetic mean.
9292
Calculates the minimum value of the input array `x`.
9393
9494
```{note}
95-
When the number of elements over which to compute the minimum value is zero, the minimum value is implementation-defined. Specification-compliant libraries may choose to error, return a sentinel value (e.g., if `x` is a floating-point input array, return `NaN`), or return the maximum possible value for the input array `x` data type (e.g., if `x` is a floating-point array, return `+infinity`).
95+
When the number of elements over which to compute the minimum value is zero, the minimum value is implementation-defined. Specification-compliant libraries may choose to raise an error, return a sentinel value (e.g., if `x` is a floating-point input array, return `NaN`), or return the maximum possible value for the input array `x` data type (e.g., if `x` is a floating-point array, return `+infinity`).
9696
```
9797

9898
#### Special Cases

0 commit comments

Comments
 (0)