Skip to content

Commit 85d3170

Browse files
authored
Clarify output dtype guidance for mean, var, and std (#260)
1 parent e810a81 commit 85d3170

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

spec/API_specification/statistical_functions.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ Calculates the arithmetic mean of the input array `x`.
6363

6464
- **out**: _<array>_
6565

66-
- if the arithmetic mean was computed over the entire array, a zero-dimensional array containing the arithmetic mean; otherwise, a non-zero-dimensional array containing the arithmetic means. The returned array must have be the default floating-point data type.
66+
- if the arithmetic mean was computed over the entire array, a zero-dimensional array containing the arithmetic mean; otherwise, a non-zero-dimensional array containing the arithmetic means. The returned array must have the same data type as `x`.
67+
68+
```{note}
69+
While this specification recommends that this function only accept input arrays having a floating-point data type, specification-compliant array libraries may choose to accept input arrays having an integer data type. While mixed data type promotion is implementation-defined, if the input array `x` has an integer data type, the returned array must have the default floating-point data type.
70+
```
6771
6872
(function-min)=
6973
### min(x, /, *, axis=None, keepdims=False)
@@ -142,7 +146,11 @@ Calculates the standard deviation of the input array `x`.
142146
143147
- **out**: _<array>_
144148
145-
- if the standard deviation was computed over the entire array, a zero-dimensional array containing the standard deviation; otherwise, a non-zero-dimensional array containing the standard deviations. The returned array must have the default floating-point data type.
149+
- if the standard deviation was computed over the entire array, a zero-dimensional array containing the standard deviation; otherwise, a non-zero-dimensional array containing the standard deviations. The returned array must have the same data type as `x`.
150+
151+
```{note}
152+
While this specification recommends that this function only accept input arrays having a floating-point data type, specification-compliant array libraries may choose to accept input arrays having an integer data type. While mixed data type promotion is implementation-defined, if the input array `x` has an integer data type, the returned array must have the default floating-point data type.
153+
```
146154
147155
(function-sum)=
148156
### sum(x, /, *, axis=None, keepdims=False)
@@ -196,4 +204,8 @@ Calculates the variance of the input array `x`.
196204
197205
- **out**: _<array>_
198206
199-
- if the variance was computed over the entire array, a zero-dimensional array containing the variance; otherwise, a non-zero-dimensional array containing the variances. The returned array must have the default floating-point data type.
207+
- if the variance was computed over the entire array, a zero-dimensional array containing the variance; otherwise, a non-zero-dimensional array containing the variances. The returned array must have the same data type as `x`.
208+
209+
```{note}
210+
While this specification recommends that this function only accept input arrays having a floating-point data type, specification-compliant array libraries may choose to accept input arrays having an integer data type. While mixed data type promotion is implementation-defined, if the input array `x` has an integer data type, the returned array must have the default floating-point data type.
211+
```

0 commit comments

Comments
 (0)