Skip to content

Commit 2146100

Browse files
committed
fix: fix multiple issues
1 parent af7c493 commit 2146100

5 files changed

Lines changed: 21 additions & 21 deletions

File tree

src/array_api/_2022_12.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7609,15 +7609,15 @@ class ArrayNamespace[TArray: Array, TDevice, TDtype](Protocol):
76097609
"Removes singleton dimensions (axes) from ``x``.\n\nParameters\n----------\nx: array\n input array.\naxis: Union[int, Tuple[int, ...]]\n axis (or axes) to squeeze. If a specified axis has a size greater than one, a ``ValueError`` must be raised.\n\nReturns\n-------\nout: array\n an output array having the same data type and elements as ``x``."
76107610
stack: stack[TArray,]
76117611
"Joins a sequence of arrays along a new axis.\n\nParameters\n----------\narrays: Union[Tuple[array, ...], List[array]]\n input arrays to join. Each array must have the same shape.\naxis: int\n axis along which the arrays will be joined. Providing an ``axis`` specifies the index of the new axis in the dimensions of the result. For example, if ``axis`` is ``0``, the new axis will be the first dimension and the output array will have shape ``(N, A, B, C)``; if ``axis`` is ``1``, the new axis will be the second dimension and the output array will have shape ``(A, N, B, C)``; and, if ``axis`` is ``-1``, the new axis will be the last dimension and the output array will have shape ``(A, B, C, N)``. A valid ``axis`` must be on the interval ``[-N, N)``, where ``N`` is the rank (number of dimensions) of ``x``. If provided an ``axis`` outside of the required interval, the function must raise an exception. Default: ``0``.\n\nReturns\n-------\nout: array\n an output array having rank ``N+1``, where ``N`` is the rank (number of dimensions) of ``x``. If the input arrays have different data types, normal :ref:`type-promotion` must apply. If the input arrays have the same data type, the output array must have the same data type as the input arrays.\n\n .. note::\n This specification leaves type promotion between data type families (i.e., ``intxx`` and ``floatxx``) unspecified."
7612-
e: float
7612+
e: TArray
76137613
"\nIEEE 754 floating-point representation of Euler's constant.\n\n``e = 2.71828182845904523536028747135266249775724709369995...``\n"
7614-
inf: float
7614+
inf: TArray
76157615
"\nIEEE 754 floating-point representation of (positive) infinity.\n"
7616-
nan: float
7616+
nan: TArray
76177617
"\nIEEE 754 floating-point representation of Not a Number (``NaN``).\n"
7618-
newaxis: float
7618+
newaxis: TArray
76197619
"\nAn alias for ``None`` which is useful for indexing arrays.\n"
7620-
pi: float
7620+
pi: TArray
76217621
"\nIEEE 754 floating-point representation of the mathematical constant ``π``.\n\n``pi = 3.1415926535897932384626433...``\n"
76227622
unique_all: unique_all[TArray,]
76237623
"Returns the unique elements of an input array ``x``, the first occurring indices for each unique element in ``x``, the indices from the set of unique elements that reconstruct ``x``, and the corresponding counts for each unique element in ``x``.\n\n.. admonition:: Data-dependent output shape\n :class: important\n\n The shapes of two of the output arrays for this function depend on the data values in the input array; hence, array libraries which build computation graphs (e.g., JAX, Dask, etc.) may find this function difficult to implement without knowing array values. Accordingly, such libraries may choose to omit this function. See :ref:`data-dependent-output-shapes` section for more details.\n\n.. note::\n Uniqueness should be determined based on value equality (see :func:`~array_api.equal`). For input arrays having floating-point data types, value-based equality implies the following behavior.\n\n - As ``nan`` values compare as ``False``, ``nan`` values should be considered distinct.\n - As complex floating-point values having at least one ``nan`` component compare as ``False``, complex floating-point values having ``nan`` components should be considered distinct.\n - As ``-0`` and ``+0`` compare as ``True``, signed zeros should not be considered distinct, and the corresponding unique element will be implementation-dependent (e.g., an implementation could choose to return ``-0`` if ``-0`` occurs before ``+0``).\n\n As signed zeros are not distinct, using ``inverse_indices`` to reconstruct the input array is not guaranteed to return an array having the exact same values.\n\n Each ``nan`` value and each complex floating-point value having a ``nan`` component should have a count of one, while the counts for signed zeros should be aggregated as a single count.\n\nParameters\n----------\nx: array\n input array. If ``x`` has more than one dimension, the function must flatten ``x`` and return the unique elements of the flattened array.\n\nReturns\n-------\nout: Tuple[array, array, array, array]\n a namedtuple ``(values, indices, inverse_indices, counts)`` whose\n\n - first element must have the field name ``values`` and must be an array containing the unique elements of ``x``. The array must have the same data type as ``x``.\n - second element must have the field name ``indices`` and must be an array containing the indices (first occurrences) of ``x`` that result in ``values``. The array must have the same shape as ``values`` and must have the default array index data type.\n - third element must have the field name ``inverse_indices`` and must be an array containing the indices of ``values`` that reconstruct ``x``. The array must have the same shape as ``x`` and must have the default array index data type.\n - fourth element must have the field name ``counts`` and must be an array containing the number of times each unique element occurs in ``x``. The returned array must have same shape as ``values`` and must have the default array index data type.\n\n .. note::\n The order of unique elements is not specified and may vary between implementations.\n\nNotes\n-----\n\n.. versionchanged:: 2022.12\n Added complex data type support."

src/array_api/_2023_12.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8457,15 +8457,15 @@ class ArrayNamespace[TArray: Array, TCapabilities, TDatatypes, TDefaultdatatypes
84578457
"Constructs an array by tiling an input array.\n\nParameters\n----------\nx: array\n input array.\nrepetitions: Tuple[int, ...]\n number of repetitions along each axis (dimension).\n\n Let ``N = len(x.shape)`` and ``M = len(repetitions)``.\n\n If ``N > M``, the function must prepend ones until all axes (dimensions) are specified (e.g., if ``x`` has shape ``(8,6,4,2)`` and ``repetitions`` is the tuple ``(3,3)``, then ``repetitions`` must be treated as ``(1,1,3,3)``).\n\n If ``N < M``, the function must prepend singleton axes (dimensions) to ``x`` until ``x`` has as many axes (dimensions) as ``repetitions`` specifies (e.g., if ``x`` has shape ``(4,2)`` and ``repetitions`` is the tuple ``(3,3,3,3)``, then ``x`` must be treated as if it has shape ``(1,1,4,2)``).\n\nReturns\n-------\nout: array\n a tiled output array. The returned array must have the same data type as ``x`` and must have a rank (i.e., number of dimensions) equal to ``max(N, M)``. If ``S`` is the shape of the tiled array after prepending singleton dimensions (if necessary) and ``r`` is the tuple of repetitions after prepending ones (if necessary), then the number of elements along each axis (dimension) must satisfy ``S[i]*r[i]``, where ``i`` refers to the ``i`` th axis (dimension).\n\nNotes\n-----\n\n.. versionadded:: 2023.12"
84588458
unstack: unstack[TArray,]
84598459
"Splits an array into a sequence of arrays along the given axis.\n\nParameters\n----------\nx: array\n input array.\naxis: int\n axis along which the array will be split. A valid ``axis`` must be on the interval ``[-N, N)``, where ``N`` is the rank (number of dimensions) of ``x``. If provided an ``axis`` outside of the required interval, the function must raise an exception. Default: ``0``.\n\nReturns\n-------\nout: Tuple[array, ...]\n tuple of slices along the given dimension. All the arrays have the same shape.\n\nNotes\n-----\n\n.. versionadded:: 2023.12"
8460-
e: float
8460+
e: TArray
84618461
"\nIEEE 754 floating-point representation of Euler's constant.\n\n``e = 2.71828182845904523536028747135266249775724709369995...``\n"
8462-
inf: float
8462+
inf: TArray
84638463
"\nIEEE 754 floating-point representation of (positive) infinity.\n"
8464-
nan: float
8464+
nan: TArray
84658465
"\nIEEE 754 floating-point representation of Not a Number (``NaN``).\n"
8466-
newaxis: float
8466+
newaxis: TArray
84678467
"\nAn alias for ``None`` which is useful for indexing arrays.\n"
8468-
pi: float
8468+
pi: TArray
84698469
"\nIEEE 754 floating-point representation of the mathematical constant ``π``.\n\n``pi = 3.1415926535897932384626433...``\n"
84708470
unique_all: unique_all[TArray,]
84718471
"Returns the unique elements of an input array ``x``, the first occurring indices for each unique element in ``x``, the indices from the set of unique elements that reconstruct ``x``, and the corresponding counts for each unique element in ``x``.\n\n.. admonition:: Data-dependent output shape\n :class: important\n\n The shapes of two of the output arrays for this function depend on the data values in the input array; hence, array libraries which build computation graphs (e.g., JAX, Dask, etc.) may find this function difficult to implement without knowing array values. Accordingly, such libraries may choose to omit this function. See :ref:`data-dependent-output-shapes` section for more details.\n\n.. note::\n Uniqueness should be determined based on value equality (see :func:`~array_api.equal`). For input arrays having floating-point data types, value-based equality implies the following behavior.\n\n - As ``nan`` values compare as ``False``, ``nan`` values should be considered distinct.\n - As complex floating-point values having at least one ``nan`` component compare as ``False``, complex floating-point values having ``nan`` components should be considered distinct.\n - As ``-0`` and ``+0`` compare as ``True``, signed zeros should not be considered distinct, and the corresponding unique element will be implementation-dependent (e.g., an implementation could choose to return ``-0`` if ``-0`` occurs before ``+0``).\n\n As signed zeros are not distinct, using ``inverse_indices`` to reconstruct the input array is not guaranteed to return an array having the exact same values.\n\n Each ``nan`` value and each complex floating-point value having a ``nan`` component should have a count of one, while the counts for signed zeros should be aggregated as a single count.\n\nParameters\n----------\nx: array\n input array. If ``x`` has more than one dimension, the function must flatten ``x`` and return the unique elements of the flattened array.\n\nReturns\n-------\nout: Tuple[array, array, array, array]\n a namedtuple ``(values, indices, inverse_indices, counts)`` whose\n\n - first element must have the field name ``values`` and must be a one-dimensional array containing the unique elements of ``x``. The array must have the same data type as ``x``.\n - second element must have the field name ``indices`` and must be an array containing the indices (first occurrences) of a flattened ``x`` that result in ``values``. The array must have the same shape as ``values`` and must have the default array index data type.\n - third element must have the field name ``inverse_indices`` and must be an array containing the indices of ``values`` that reconstruct ``x``. The array must have the same shape as ``x`` and must have the default array index data type.\n - fourth element must have the field name ``counts`` and must be an array containing the number of times each unique element occurs in ``x``. The order of the returned counts must match the order of ``values``, such that a specific element in ``counts`` corresponds to the respective unique element in ``values``. The returned array must have same shape as ``values`` and must have the default array index data type.\n\n .. note::\n The order of unique elements is not specified and may vary between implementations.\n\nNotes\n-----\n\n.. versionchanged:: 2022.12\n Added complex data type support.\n\n.. versionchanged:: 2023.12\n Clarified flattening behavior and required the order of ``counts`` match the order of ``values``."

src/array_api/_2024_12.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8942,15 +8942,15 @@ class ArrayNamespace[TArray: Array, TCapabilities, TDatatypes, TDefaultdatatypes
89428942
"Constructs an array by tiling an input array.\n\nParameters\n----------\nx: array\n input array.\nrepetitions: Tuple[int, ...]\n number of repetitions along each axis (dimension).\n\n Let ``N = len(x.shape)`` and ``M = len(repetitions)``.\n\n If ``N > M``, the function must prepend ones until all axes (dimensions) are specified (e.g., if ``x`` has shape ``(8,6,4,2)`` and ``repetitions`` is the tuple ``(3,3)``, then ``repetitions`` must be treated as ``(1,1,3,3)``).\n\n If ``N < M``, the function must prepend singleton axes (dimensions) to ``x`` until ``x`` has as many axes (dimensions) as ``repetitions`` specifies (e.g., if ``x`` has shape ``(4,2)`` and ``repetitions`` is the tuple ``(3,3,3,3)``, then ``x`` must be treated as if it has shape ``(1,1,4,2)``).\n\nReturns\n-------\nout: array\n a tiled output array. The returned array must have the same data type as ``x`` and must have a rank (i.e., number of dimensions) equal to ``max(N, M)``. If ``S`` is the shape of the tiled array after prepending singleton dimensions (if necessary) and ``r`` is the tuple of repetitions after prepending ones (if necessary), then the number of elements along each axis (dimension) must satisfy ``S[i]*r[i]``, where ``i`` refers to the ``i`` th axis (dimension).\n\nNotes\n-----\n\n.. versionadded:: 2023.12"
89438943
unstack: unstack[TArray,]
89448944
"Splits an array into a sequence of arrays along the given axis.\n\nParameters\n----------\nx: array\n input array.\naxis: int\n axis along which the array will be split. A valid ``axis`` must be on the interval ``[-N, N)``, where ``N`` is the rank (number of dimensions) of ``x``. If provided an ``axis`` outside of the required interval, the function must raise an exception. Default: ``0``.\n\nReturns\n-------\nout: Tuple[array, ...]\n tuple of slices along the given dimension. All the arrays have the same shape.\n\nNotes\n-----\n\n.. versionadded:: 2023.12"
8945-
e: float
8945+
e: TArray
89468946
"\nIEEE 754 floating-point representation of Euler's constant.\n\n``e = 2.71828182845904523536028747135266249775724709369995...``\n"
8947-
inf: float
8947+
inf: TArray
89488948
"\nIEEE 754 floating-point representation of (positive) infinity.\n"
8949-
nan: float
8949+
nan: TArray
89508950
"\nIEEE 754 floating-point representation of Not a Number (``NaN``).\n"
8951-
newaxis: float
8951+
newaxis: TArray
89528952
"\nAn alias for ``None`` which is useful for indexing arrays.\n"
8953-
pi: float
8953+
pi: TArray
89548954
"\nIEEE 754 floating-point representation of the mathematical constant ``π``.\n\n``pi = 3.1415926535897932384626433...``\n"
89558955
unique_all: unique_all[TArray,]
89568956
"Returns the unique elements of an input array ``x``, the first occurring indices for each unique element in ``x``, the indices from the set of unique elements that reconstruct ``x``, and the corresponding counts for each unique element in ``x``.\n\n.. admonition:: Data-dependent output shape\n :class: important\n\n The shapes of two of the output arrays for this function depend on the data values in the input array; hence, array libraries which build computation graphs (e.g., JAX, Dask, etc.) may find this function difficult to implement without knowing array values. Accordingly, such libraries may choose to omit this function. See :ref:`data-dependent-output-shapes` section for more details.\n\n.. note::\n Uniqueness should be determined based on value equality (see :func:`~array_api.equal`). For input arrays having floating-point data types, value-based equality implies the following behavior.\n\n - As ``nan`` values compare as ``False``, ``nan`` values should be considered distinct.\n - As complex floating-point values having at least one ``nan`` component compare as ``False``, complex floating-point values having ``nan`` components should be considered distinct.\n - As ``-0`` and ``+0`` compare as ``True``, signed zeros should not be considered distinct, and the corresponding unique element will be implementation-dependent (e.g., an implementation could choose to return ``-0`` if ``-0`` occurs before ``+0``).\n\n As signed zeros are not distinct, using ``inverse_indices`` to reconstruct the input array is not guaranteed to return an array having the exact same values.\n\n Each ``nan`` value and each complex floating-point value having a ``nan`` component should have a count of one, while the counts for signed zeros should be aggregated as a single count.\n\nParameters\n----------\nx: array\n input array. If ``x`` has more than one dimension, the function must flatten ``x`` and return the unique elements of the flattened array.\n\nReturns\n-------\nout: Tuple[array, array, array, array]\n a namedtuple ``(values, indices, inverse_indices, counts)`` whose\n\n - first element must have the field name ``values`` and must be a one-dimensional array containing the unique elements of ``x``. The array must have the same data type as ``x``.\n - second element must have the field name ``indices`` and must be an array containing the indices (first occurrences) of a flattened ``x`` that result in ``values``. The array must have the same shape as ``values`` and must have the default array index data type.\n - third element must have the field name ``inverse_indices`` and must be an array containing the indices of ``values`` that reconstruct ``x``. The array must have the same shape as ``x`` and must have the default array index data type.\n - fourth element must have the field name ``counts`` and must be an array containing the number of times each unique element occurs in ``x``. The order of the returned counts must match the order of ``values``, such that a specific element in ``counts`` corresponds to the respective unique element in ``values``. The returned array must have same shape as ``values`` and must have the default array index data type.\n\n .. note::\n The order of unique elements is not specified and may vary between implementations.\n\nNotes\n-----\n\n.. versionchanged:: 2022.12\n Added complex data type support.\n\n.. versionchanged:: 2023.12\n Clarified flattening behavior and required the order of ``counts`` match the order of ``values``."

0 commit comments

Comments
 (0)