From 0238246321d3ade92b68928451a07102e940af8f Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 7 Jan 2022 10:25:05 +0000 Subject: [PATCH 1/5] Make int inputs for divide functions out-of-scope --- spec/API_specification/array_object.md | 4 ++++ spec/API_specification/elementwise_functions.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/spec/API_specification/array_object.md b/spec/API_specification/array_object.md index 7eeddd4eb..9712008d3 100644 --- a/spec/API_specification/array_object.md +++ b/spec/API_specification/array_object.md @@ -1249,6 +1249,10 @@ Element-wise results must equal the results returned by the equivalent element-w Evaluates `self_i / other_i` for each element of an array instance with the respective element of the array `other`. +```{note} +If one or both of `self` and `other` have integer data types, the result is unspecified and thus implementation-dependent. +``` + #### Special Cases For floating-point operands, let `self` equal `x1` and `other` equal `x2`. diff --git a/spec/API_specification/elementwise_functions.md b/spec/API_specification/elementwise_functions.md index f7adb7373..4226b9a07 100644 --- a/spec/API_specification/elementwise_functions.md +++ b/spec/API_specification/elementwise_functions.md @@ -528,6 +528,10 @@ For floating-point operands, Calculates the division for each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`. +```{note} +If one or both of the input arrays have integer data types, the result is unspecified and thus implementation-dependent. +``` + #### Special Cases For floating-point operands, From 6632131864ad40fe9eacd52b7b6a43ce76f48d01 Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 10 Jan 2022 12:57:10 +0000 Subject: [PATCH 2/5] Clarify mixed kind promotion is unspecified for divide notes --- spec/API_specification/array_object.md | 2 +- spec/API_specification/elementwise_functions.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/API_specification/array_object.md b/spec/API_specification/array_object.md index 9712008d3..ac6a34912 100644 --- a/spec/API_specification/array_object.md +++ b/spec/API_specification/array_object.md @@ -1250,7 +1250,7 @@ Element-wise results must equal the results returned by the equivalent element-w Evaluates `self_i / other_i` for each element of an array instance with the respective element of the array `other`. ```{note} -If one or both of `self` and `other` have integer data types, the result is unspecified and thus implementation-dependent. +If one or both of `self` and `other` have integer data types, the result is unspecified and thus implementation-dependent (type promotion between data type “kinds” (integer versus floating-point) is unspecified). ``` #### Special Cases diff --git a/spec/API_specification/elementwise_functions.md b/spec/API_specification/elementwise_functions.md index 4226b9a07..4a850839f 100644 --- a/spec/API_specification/elementwise_functions.md +++ b/spec/API_specification/elementwise_functions.md @@ -529,7 +529,7 @@ For floating-point operands, Calculates the division for each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`. ```{note} -If one or both of the input arrays have integer data types, the result is unspecified and thus implementation-dependent. +If one or both of the input arrays have integer data types, the result is unspecified and thus implementation-dependent (type promotion between data type “kinds” (integer versus floating-point) is unspecified). ``` #### Special Cases From d1d072b42cbf7a7e34237e107ff62f1c526e757c Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 10 Jan 2022 13:11:52 +0000 Subject: [PATCH 3/5] Clearer language for noting mixed kind promotion --- spec/API_specification/array_object.md | 4 ++-- spec/API_specification/elementwise_functions.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/API_specification/array_object.md b/spec/API_specification/array_object.md index ac6a34912..7805a737e 100644 --- a/spec/API_specification/array_object.md +++ b/spec/API_specification/array_object.md @@ -1115,7 +1115,7 @@ Calculates an implementation-dependent approximation of exponentiation by raisin ```{note} 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. -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). +If `self` has an integer data type and `other` has a floating-point data type, behavior is implementation-dependent. This is because type promotion between data type “kinds” (i.e. integer versus floating-point) is unspecified. ``` #### Special Cases @@ -1250,7 +1250,7 @@ Element-wise results must equal the results returned by the equivalent element-w Evaluates `self_i / other_i` for each element of an array instance with the respective element of the array `other`. ```{note} -If one or both of `self` and `other` have integer data types, the result is unspecified and thus implementation-dependent (type promotion between data type “kinds” (integer versus floating-point) is unspecified). +If one or both of `self` and `other` have integer data types, the result is unspecified and thus implementation-dependent. This is because type promotion between data type “kinds” (i.e. integer versus floating-point) is unspecified. ``` #### Special Cases diff --git a/spec/API_specification/elementwise_functions.md b/spec/API_specification/elementwise_functions.md index 4a850839f..687ad1fe3 100644 --- a/spec/API_specification/elementwise_functions.md +++ b/spec/API_specification/elementwise_functions.md @@ -529,7 +529,7 @@ For floating-point operands, Calculates the division for each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`. ```{note} -If one or both of the input arrays have integer data types, the result is unspecified and thus implementation-dependent (type promotion between data type “kinds” (integer versus floating-point) is unspecified). +If one or both of the input arrays have integer data types, the result is unspecified and thus implementation-dependent. This is because type promotion between data type “kinds” (i.e. integer versus floating-point) is unspecified. ``` #### Special Cases @@ -1227,7 +1227,7 @@ Calculates an implementation-dependent approximation of exponentiation by raisin ```{note} 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. -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). +If `x1` has an integer data type and `x2` has a floating-point data type, behavior is implementation-dependent. This is because type promotion between data type “kinds” (i.e. integer versus floating-point) is unspecified. ``` #### Special Cases From 5efe64c41607f2588a443848677c02d16357d000 Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 10 Jan 2022 13:21:04 +0000 Subject: [PATCH 4/5] Prohibit div functions return int arrays Also fixes related note wording for `min()` and `max()` --- spec/API_specification/array_object.md | 4 +++- spec/API_specification/elementwise_functions.md | 4 +++- spec/API_specification/statistical_functions.md | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/spec/API_specification/array_object.md b/spec/API_specification/array_object.md index 7805a737e..4fb694cf5 100644 --- a/spec/API_specification/array_object.md +++ b/spec/API_specification/array_object.md @@ -1250,7 +1250,9 @@ Element-wise results must equal the results returned by the equivalent element-w Evaluates `self_i / other_i` for each element of an array instance with the respective element of the array `other`. ```{note} -If one or both of `self` and `other` have integer data types, the result is unspecified and thus implementation-dependent. This is because type promotion between data type “kinds” (i.e. integer versus floating-point) is unspecified. +If one or both of `self` and `other` have integer data types, the result is implementation-dependent. This is because type promotion between data type “kinds” (i.e. integer versus floating-point) is unspecified. + +Specification-compliant libraries may choose to raise an error or return an array containing the element-wise results. If an array is returned, it must have a floating-point data type. ``` #### Special Cases diff --git a/spec/API_specification/elementwise_functions.md b/spec/API_specification/elementwise_functions.md index 687ad1fe3..c57a4414d 100644 --- a/spec/API_specification/elementwise_functions.md +++ b/spec/API_specification/elementwise_functions.md @@ -529,7 +529,9 @@ For floating-point operands, Calculates the division for each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`. ```{note} -If one or both of the input arrays have integer data types, the result is unspecified and thus implementation-dependent. This is because type promotion between data type “kinds” (i.e. integer versus floating-point) is unspecified. +If one or both of the input arrays have integer data types, the result is implementation-dependent. This is because type promotion between data type “kinds” (i.e. integer versus floating-point) is unspecified. + +Specification-compliant libraries may choose to raise an error or return an array containing the element-wise results. If an array is returned, it must have a floating-point data type. ``` #### Special Cases diff --git a/spec/API_specification/statistical_functions.md b/spec/API_specification/statistical_functions.md index fb0ca7c21..052cbcbbd 100644 --- a/spec/API_specification/statistical_functions.md +++ b/spec/API_specification/statistical_functions.md @@ -21,7 +21,7 @@ A conforming implementation of the array API standard must provide and support t Calculates the maximum value of the input array `x`. ```{note} -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`). +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`). ``` #### Special Cases @@ -92,7 +92,7 @@ Let `N` equal the number of elements over which to compute the arithmetic mean. Calculates the minimum value of the input array `x`. ```{note} -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`). +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`). ``` #### Special Cases From 807adbf79163d1f2d4bbc65a2977d436307a990f Mon Sep 17 00:00:00 2001 From: Matthew Barber Date: Mon, 10 Jan 2022 19:34:37 +0000 Subject: [PATCH 5/5] Better legibility of mixed kinds note Co-authored-by: Athan --- spec/API_specification/array_object.md | 6 +++--- spec/API_specification/elementwise_functions.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/API_specification/array_object.md b/spec/API_specification/array_object.md index 4fb694cf5..46ba3648e 100644 --- a/spec/API_specification/array_object.md +++ b/spec/API_specification/array_object.md @@ -1115,7 +1115,7 @@ Calculates an implementation-dependent approximation of exponentiation by raisin ```{note} 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. -If `self` has an integer data type and `other` has a floating-point data type, behavior is implementation-dependent. This is because type promotion between data type “kinds” (i.e. integer versus floating-point) is unspecified. +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. ``` #### Special Cases @@ -1250,9 +1250,9 @@ Element-wise results must equal the results returned by the equivalent element-w Evaluates `self_i / other_i` for each element of an array instance with the respective element of the array `other`. ```{note} -If one or both of `self` and `other` have integer data types, the result is implementation-dependent. This is because type promotion between data type “kinds” (i.e. integer versus floating-point) is unspecified. +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. -Specification-compliant libraries may choose to raise an error or return an array containing the element-wise results. If an array is returned, it must have a floating-point data type. +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. ``` #### Special Cases diff --git a/spec/API_specification/elementwise_functions.md b/spec/API_specification/elementwise_functions.md index c57a4414d..9602f5f7c 100644 --- a/spec/API_specification/elementwise_functions.md +++ b/spec/API_specification/elementwise_functions.md @@ -529,9 +529,9 @@ For floating-point operands, Calculates the division for each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`. ```{note} -If one or both of the input arrays have integer data types, the result is implementation-dependent. This is because type promotion between data type “kinds” (i.e. integer versus floating-point) is unspecified. +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. -Specification-compliant libraries may choose to raise an error or return an array containing the element-wise results. If an array is returned, it must have a floating-point data type. +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. ``` #### Special Cases @@ -1229,7 +1229,7 @@ Calculates an implementation-dependent approximation of exponentiation by raisin ```{note} 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. -If `x1` has an integer data type and `x2` has a floating-point data type, behavior is implementation-dependent. This is because type promotion between data type “kinds” (i.e. integer versus floating-point) is unspecified. +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. ``` #### Special Cases