You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/array_api_stubs/_draft/statistical_functions.py
+20-20Lines changed: 20 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@
14
14
from ._typesimportOptional, Tuple, Union, array, dtype
15
15
16
16
17
-
defcumulative_sum(
17
+
defcumulative_prod(
18
18
x: array,
19
19
/,
20
20
*,
@@ -23,14 +23,14 @@ def cumulative_sum(
23
23
include_initial: bool=False,
24
24
) ->array:
25
25
"""
26
-
Calculates the cumulative sum of elements in the input array ``x``.
26
+
Calculates the cumulative product of elements in the input array ``x``.
27
27
28
28
Parameters
29
29
----------
30
30
x: array
31
31
input array. Should have a numeric data type.
32
32
axis: Optional[int]
33
-
axis along which a cumulative sum must be computed. If ``axis`` is negative, the function must determine the axis along which to compute a cumulative sum by counting from the last dimension.
33
+
axis along which a cumulative product must be computed. If ``axis`` is negative, the function must determine the axis along which to compute a cumulative product by counting from the last dimension.
34
34
35
35
If ``x`` is a one-dimensional array, providing an ``axis`` is optional; however, if ``x`` has more than one dimension, providing an ``axis`` is required.
36
36
@@ -40,33 +40,31 @@ def cumulative_sum(
40
40
- if ``x`` has a signed integer data type (e.g., ``int16``), the returned array must have the default integer data type.
41
41
- if ``x`` has an unsigned integer data type (e.g., ``uint16``), the returned array must have an unsigned integer data type having the same number of bits as the default integer data type (e.g., if the default integer data type is ``int32``, the returned array must have a ``uint32`` data type).
42
42
43
-
If the data type (either specified or resolved) differs from the data type of ``x``, the input array should be cast to the specified data type before computing the sum (rationale: the ``dtype`` keyword argument is intended to help prevent overflows). Default: ``None``.
43
+
If the data type (either specified or resolved) differs from the data type of ``x``, the input array should be cast to the specified data type before computing the product (rationale: the ``dtype`` keyword argument is intended to help prevent overflows). Default: ``None``.
44
44
45
45
include_initial: bool
46
-
boolean indicating whether to include the initial value as the first value in the output. By convention, the initial value must be the additive identity (i.e., zero). Default: ``False``.
46
+
boolean indicating whether to include the initial value as the first value in the output. By convention, the initial value must be the multiplicative identity (i.e., one). Default: ``False``.
47
47
48
48
Returns
49
49
-------
50
50
out: array
51
-
an array containing the cumulative sums. The returned array must have a data type as described by the ``dtype`` parameter above.
51
+
an array containing the cumulative products. The returned array must have a data type as described by the ``dtype`` parameter above.
52
52
53
-
Let ``N`` be the size of the axis along which to compute the cumulative sum. The returned array must have a shape determined according to the following rules:
53
+
Let ``N`` be the size of the axis along which to compute the cumulative product. The returned array must have a shape determined according to the following rules:
54
54
55
-
- if ``include_initial`` is ``True``, the returned array must have the same shape as ``x``, except the size of the axis along which to compute the cumulative sum must be ``N+1``.
55
+
- if ``include_initial`` is ``True``, the returned array must have the same shape as ``x``, except the size of the axis along which to compute the cumulative product must be ``N+1``.
56
56
- if ``include_initial`` is ``False``, the returned array must have the same shape as ``x``.
57
57
58
58
Notes
59
59
-----
60
60
61
61
**Special Cases**
62
62
63
-
For both real-valued and complex floating-point operands, special cases must be handled as if the operation is implemented by successive application of :func:`~array_api.add`.
64
-
65
-
.. versionadded:: 2023.12
63
+
For both real-valued and complex floating-point operands, special cases must be handled as if the operation is implemented by successive application of :func:`~array_api.multiply`.
66
64
"""
67
65
68
66
69
-
defcumulative_prod(
67
+
defcumulative_sum(
70
68
x: array,
71
69
/,
72
70
*,
@@ -75,14 +73,14 @@ def cumulative_prod(
75
73
include_initial: bool=False,
76
74
) ->array:
77
75
"""
78
-
Calculates the cumulative product of elements in the input array ``x``.
76
+
Calculates the cumulative sum of elements in the input array ``x``.
79
77
80
78
Parameters
81
79
----------
82
80
x: array
83
81
input array. Should have a numeric data type.
84
82
axis: Optional[int]
85
-
axis along which a cumulative product must be computed. If ``axis`` is negative, the function must determine the axis along which to compute a cumulative product by counting from the last dimension.
83
+
axis along which a cumulative sum must be computed. If ``axis`` is negative, the function must determine the axis along which to compute a cumulative sum by counting from the last dimension.
86
84
87
85
If ``x`` is a one-dimensional array, providing an ``axis`` is optional; however, if ``x`` has more than one dimension, providing an ``axis`` is required.
88
86
@@ -92,27 +90,29 @@ def cumulative_prod(
92
90
- if ``x`` has a signed integer data type (e.g., ``int16``), the returned array must have the default integer data type.
93
91
- if ``x`` has an unsigned integer data type (e.g., ``uint16``), the returned array must have an unsigned integer data type having the same number of bits as the default integer data type (e.g., if the default integer data type is ``int32``, the returned array must have a ``uint32`` data type).
94
92
95
-
If the data type (either specified or resolved) differs from the data type of ``x``, the input array should be cast to the specified data type before computing the product (rationale: the ``dtype`` keyword argument is intended to help prevent overflows). Default: ``None``.
93
+
If the data type (either specified or resolved) differs from the data type of ``x``, the input array should be cast to the specified data type before computing the sum (rationale: the ``dtype`` keyword argument is intended to help prevent overflows). Default: ``None``.
96
94
97
95
include_initial: bool
98
-
boolean indicating whether to include the initial value as the first value in the output. By convention, the initial value must be the multiplicative identity (i.e., one). Default: ``False``.
96
+
boolean indicating whether to include the initial value as the first value in the output. By convention, the initial value must be the additive identity (i.e., zero). Default: ``False``.
99
97
100
98
Returns
101
99
-------
102
100
out: array
103
-
an array containing the cumulative products. The returned array must have a data type as described by the ``dtype`` parameter above.
101
+
an array containing the cumulative sums. The returned array must have a data type as described by the ``dtype`` parameter above.
104
102
105
-
Let ``N`` be the size of the axis along which to compute the cumulative product. The returned array must have a shape determined according to the following rules:
103
+
Let ``N`` be the size of the axis along which to compute the cumulative sum. The returned array must have a shape determined according to the following rules:
106
104
107
-
- if ``include_initial`` is ``True``, the returned array must have the same shape as ``x``, except the size of the axis along which to compute the cumulative product must be ``N+1``.
105
+
- if ``include_initial`` is ``True``, the returned array must have the same shape as ``x``, except the size of the axis along which to compute the cumulative sum must be ``N+1``.
108
106
- if ``include_initial`` is ``False``, the returned array must have the same shape as ``x``.
109
107
110
108
Notes
111
109
-----
112
110
113
111
**Special Cases**
114
112
115
-
For both real-valued and complex floating-point operands, special cases must be handled as if the operation is implemented by successive application of :func:`~array_api.multiply`.
113
+
For both real-valued and complex floating-point operands, special cases must be handled as if the operation is implemented by successive application of :func:`~array_api.add`.
0 commit comments