Skip to content

Commit 3b2386e

Browse files
committed
style: reorder APIs in alphabetical order
1 parent 8034b88 commit 3b2386e

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/array_api_stubs/_draft/statistical_functions.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from ._types import Optional, Tuple, Union, array, dtype
1515

1616

17-
def cumulative_sum(
17+
def cumulative_prod(
1818
x: array,
1919
/,
2020
*,
@@ -23,14 +23,14 @@ def cumulative_sum(
2323
include_initial: bool = False,
2424
) -> array:
2525
"""
26-
Calculates the cumulative sum of elements in the input array ``x``.
26+
Calculates the cumulative product of elements in the input array ``x``.
2727
2828
Parameters
2929
----------
3030
x: array
3131
input array. Should have a numeric data type.
3232
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.
3434
3535
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.
3636
@@ -40,33 +40,31 @@ def cumulative_sum(
4040
- if ``x`` has a signed integer data type (e.g., ``int16``), the returned array must have the default integer data type.
4141
- 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).
4242
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``.
4444
4545
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``.
4747
4848
Returns
4949
-------
5050
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.
5252
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:
5454
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``.
5656
- if ``include_initial`` is ``False``, the returned array must have the same shape as ``x``.
5757
5858
Notes
5959
-----
6060
6161
**Special Cases**
6262
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`.
6664
"""
6765

6866

69-
def cumulative_prod(
67+
def cumulative_sum(
7068
x: array,
7169
/,
7270
*,
@@ -75,14 +73,14 @@ def cumulative_prod(
7573
include_initial: bool = False,
7674
) -> array:
7775
"""
78-
Calculates the cumulative product of elements in the input array ``x``.
76+
Calculates the cumulative sum of elements in the input array ``x``.
7977
8078
Parameters
8179
----------
8280
x: array
8381
input array. Should have a numeric data type.
8482
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.
8684
8785
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.
8886
@@ -92,27 +90,29 @@ def cumulative_prod(
9290
- if ``x`` has a signed integer data type (e.g., ``int16``), the returned array must have the default integer data type.
9391
- 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).
9492
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``.
9694
9795
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``.
9997
10098
Returns
10199
-------
102100
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.
104102
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:
106104
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``.
108106
- if ``include_initial`` is ``False``, the returned array must have the same shape as ``x``.
109107
110108
Notes
111109
-----
112110
113111
**Special Cases**
114112
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`.
114+
115+
.. versionadded:: 2023.12
116116
"""
117117

118118

0 commit comments

Comments
 (0)