Skip to content

Commit 399cf52

Browse files
authored
Backport version added and changed annotations to 2022.12 specification
2 parents 8a3e6bc + d89e7a7 commit 399cf52

11 files changed

+495
-0
lines changed

src/array_api_stubs/_2022_12/array_object.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,14 @@ def __abs__(self: array, /) -> array:
136136
out: array
137137
an array containing the element-wise absolute value. If ``self`` has a real-valued data type, the returned array must have the same data type as ``self``. If ``self`` has a complex floating-point data type, the returned arrayed must have a real-valued floating-point data type whose precision matches the precision of ``self`` (e.g., if ``self`` is ``complex128``, then the returned array must have a ``float64`` data type).
138138
139+
Notes
140+
-----
139141
140142
.. note::
141143
Element-wise results, including special cases, must equal the results returned by the equivalent element-wise function :func:`~array_api.abs`.
144+
145+
.. versionchanged:: 2022.12
146+
Added complex data type support.
142147
"""
143148

144149
def __add__(self: array, other: Union[int, float, array], /) -> array:
@@ -157,9 +162,14 @@ def __add__(self: array, other: Union[int, float, array], /) -> array:
157162
out: array
158163
an array containing the element-wise sums. The returned array must have a data type determined by :ref:`type-promotion`.
159164
165+
Notes
166+
-----
160167
161168
.. note::
162169
Element-wise results, including special cases, must equal the results returned by the equivalent element-wise function :func:`~array_api.add`.
170+
171+
.. versionchanged:: 2022.12
172+
Added complex data type support.
163173
"""
164174

165175
def __and__(self: array, other: Union[int, bool, array], /) -> array:
@@ -228,6 +238,9 @@ def __bool__(self: array, /) -> bool:
228238
- If ``self`` is either ``+0`` or ``-0``, the result is ``False``.
229239
230240
For complex floating-point operands, special cases must be handled as if the operation is implemented as the logical AND of ``bool(real(self))`` and ``bool(imag(self))``.
241+
242+
.. versionchanged:: 2022.12
243+
Added boolean and complex data type support.
231244
"""
232245

233246
def __complex__(self: array, /) -> complex:
@@ -260,6 +273,8 @@ def __complex__(self: array, /) -> complex:
260273
- If ``self`` is ``+infinity``, the result is ``+infinity + 0j``.
261274
- If ``self`` is ``-infinity``, the result is ``-infinity + 0j``.
262275
- If ``self`` is a finite number, the result is ``self + 0j``.
276+
277+
.. versionadded:: 2022.12
263278
"""
264279

265280
def __dlpack__(
@@ -326,6 +341,11 @@ def __dlpack__(
326341
errors are raised when export fails for other reasons (e.g., incorrect
327342
arguments passed or out of memory).
328343
344+
Notes
345+
-----
346+
347+
.. versionchanged:: 2022.12
348+
Added BufferError.
329349
"""
330350

331351
def __dlpack_device__(self: array, /) -> Tuple[Enum, int]:
@@ -401,6 +421,9 @@ def __float__(self: array, /) -> float:
401421
402422
- If ``self`` is ``True``, the result is ``1``.
403423
- If ``self`` is ``False``, the result is ``0``.
424+
425+
.. versionchanged:: 2022.12
426+
Added boolean and complex data type support.
404427
"""
405428

406429
def __floordiv__(self: array, other: Union[int, float, array], /) -> array:
@@ -551,6 +574,9 @@ def __int__(self: array, /) -> int:
551574
552575
- If ``self`` is either ``+infinity`` or ``-infinity``, raise ``OverflowError``.
553576
- If ``self`` is ``NaN``, raise ``ValueError``.
577+
578+
.. versionchanged:: 2022.12
579+
Added boolean and complex data type support.
554580
"""
555581

556582
def __invert__(self: array, /) -> array:
@@ -671,6 +697,8 @@ def __matmul__(self: array, other: array, /) -> array:
671697
- if either ``self`` or ``other`` has more than two dimensions, an array having a shape determined by :ref:`broadcasting` ``shape(self)[:-2]`` against ``shape(other)[:-2]`` and containing the `conventional matrix product <https://en.wikipedia.org/wiki/Matrix_multiplication>`_ for each stacked matrix.
672698
- The returned array must have a data type determined by :ref:`type-promotion`.
673699
700+
Notes
701+
-----
674702
675703
.. note::
676704
Results must equal the results returned by the equivalent function :func:`~array_api.matmul`.
@@ -682,6 +710,9 @@ def __matmul__(self: array, other: array, /) -> array:
682710
- if ``self`` is a one-dimensional array having shape ``(K,)``, ``other`` is an array having shape ``(..., L, N)``, and ``K != L``.
683711
- if ``self`` is an array having shape ``(..., M, K)``, ``other`` is a one-dimensional array having shape ``(L,)``, and ``K != L``.
684712
- if ``self`` is an array having shape ``(..., M, K)``, ``other`` is an array having shape ``(..., L, N)``, and ``K != L``.
713+
714+
.. versionchanged:: 2022.12
715+
Added complex data type support.
685716
"""
686717

687718
def __mod__(self: array, other: Union[int, float, array], /) -> array:
@@ -727,9 +758,14 @@ def __mul__(self: array, other: Union[int, float, array], /) -> array:
727758
out: array
728759
an array containing the element-wise products. The returned array must have a data type determined by :ref:`type-promotion`.
729760
761+
Notes
762+
-----
730763
731764
.. note::
732765
Element-wise results, including special cases, must equal the results returned by the equivalent element-wise function :func:`~array_api.multiply`.
766+
767+
.. versionchanged:: 2022.12
768+
Added complex data type support.
733769
"""
734770

735771
def __ne__(self: array, other: Union[int, float, bool, array], /) -> array:
@@ -748,9 +784,14 @@ def __ne__(self: array, other: Union[int, float, bool, array], /) -> array:
748784
out: array
749785
an array containing the element-wise results. The returned array must have a data type of ``bool`` (i.e., must be a boolean array).
750786
787+
Notes
788+
-----
751789
752790
.. note::
753791
Element-wise results, including special cases, must equal the results returned by the equivalent element-wise function :func:`~array_api.not_equal`.
792+
793+
.. versionchanged:: 2022.12
794+
Added complex data type support.
754795
"""
755796

756797
def __neg__(self: array, /) -> array:
@@ -773,9 +814,14 @@ def __neg__(self: array, /) -> array:
773814
out: array
774815
an array containing the evaluated result for each element in ``self``. The returned array must have a data type determined by :ref:`type-promotion`.
775816
817+
Notes
818+
-----
776819
777820
.. note::
778821
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.negative`.
822+
823+
.. versionchanged:: 2022.12
824+
Added complex data type support.
779825
"""
780826

781827
def __or__(self: array, other: Union[int, bool, array], /) -> array:
@@ -794,9 +840,14 @@ def __or__(self: array, other: Union[int, bool, array], /) -> array:
794840
out: array
795841
an array containing the element-wise results. The returned array must have a data type determined by :ref:`type-promotion`.
796842
843+
Notes
844+
-----
797845
798846
.. note::
799847
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.bitwise_or`.
848+
849+
.. versionchanged:: 2022.12
850+
Added complex data type support.
800851
"""
801852

802853
def __pos__(self: array, /) -> array:
@@ -839,9 +890,14 @@ def __pow__(self: array, other: Union[int, float, array], /) -> array:
839890
out: array
840891
an array containing the element-wise results. The returned array must have a data type determined by :ref:`type-promotion`.
841892
893+
Notes
894+
-----
842895
843896
.. note::
844897
Element-wise results, including special cases, must equal the results returned by the equivalent element-wise function :func:`~array_api.pow`.
898+
899+
.. versionchanged:: 2022.12
900+
Added complex data type support.
845901
"""
846902

847903
def __rshift__(self: array, other: Union[int, array], /) -> array:
@@ -913,9 +969,14 @@ def __sub__(self: array, other: Union[int, float, array], /) -> array:
913969
out: array
914970
an array containing the element-wise differences. The returned array must have a data type determined by :ref:`type-promotion`.
915971
972+
Notes
973+
-----
916974
917975
.. note::
918976
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.subtract`.
977+
978+
.. versionchanged:: 2022.12
979+
Added complex data type support.
919980
"""
920981

921982
def __truediv__(self: array, other: Union[int, float, array], /) -> array:
@@ -939,9 +1000,14 @@ def __truediv__(self: array, other: Union[int, float, array], /) -> array:
9391000
out: array
9401001
an array containing the element-wise results. The returned array should have a floating-point data type determined by :ref:`type-promotion`.
9411002
1003+
Notes
1004+
-----
9421005
9431006
.. note::
9441007
Element-wise results, including special cases, must equal the results returned by the equivalent element-wise function :func:`~array_api.divide`.
1008+
1009+
.. versionchanged:: 2022.12
1010+
Added complex data type support.
9451011
"""
9461012

9471013
def __xor__(self: array, other: Union[int, bool, array], /) -> array:

src/array_api_stubs/_2022_12/creation_functions.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ def asarray(
9797
-------
9898
out: array
9999
an array containing the data from ``obj``.
100+
101+
Notes
102+
-----
103+
104+
.. versionchanged:: 2022.12
105+
Added complex data type support.
100106
"""
101107

102108

@@ -179,6 +185,12 @@ def eye(
179185
-------
180186
out: array
181187
an array where all elements are equal to zero, except for the ``k``\th diagonal, whose values are equal to one.
188+
189+
Notes
190+
-----
191+
192+
.. versionchanged:: 2022.12
193+
Added complex data type support.
182194
"""
183195

184196

@@ -237,6 +249,12 @@ def full(
237249
-------
238250
out: array
239251
an array where every element is equal to ``fill_value``.
252+
253+
Notes
254+
-----
255+
256+
.. versionchanged:: 2022.12
257+
Added complex data type support.
240258
"""
241259

242260

@@ -273,6 +291,12 @@ def full_like(
273291
-------
274292
out: array
275293
an array having the same shape as ``x`` and where every element is equal to ``fill_value``.
294+
295+
Notes
296+
-----
297+
298+
.. versionchanged:: 2022.12
299+
Added complex data type support.
276300
"""
277301

278302

@@ -334,12 +358,17 @@ def linspace(
334358
out: array
335359
a one-dimensional array containing evenly spaced values.
336360
361+
Notes
362+
-----
337363
338364
.. note::
339365
While this specification recommends that this function only return arrays having a floating-point data type, specification-compliant array libraries may choose to support output arrays having an integer data type (e.g., due to backward compatibility concerns). However, function behavior when generating integer output arrays is unspecified and, thus, is implementation-defined. Accordingly, using this function to generate integer output arrays is not portable.
340366
341367
.. note::
342368
As mixed data type promotion is implementation-defined, behavior when ``start`` or ``stop`` exceeds the maximum safe integer of an output floating-point data type is implementation-defined. An implementation may choose to overflow or raise an exception.
369+
370+
.. versionchanged:: 2022.12
371+
Added complex data type support.
343372
"""
344373

345374

@@ -367,6 +396,12 @@ def meshgrid(*arrays: array, indexing: str = "xy") -> List[array]:
367396
Similarly, for the three-dimensional case with input one-dimensional arrays of length ``M``, ``N``, and ``P``, if matrix indexing ``ij``, then each returned array must have shape ``(M, N, P)``, and, if Cartesian indexing ``xy``, then each returned array must have shape ``(N, M, P)``.
368397
369398
Each returned array should have the same data type as the input arrays.
399+
400+
Notes
401+
-----
402+
403+
.. versionchanged:: 2022.12
404+
Added complex data type support.
370405
"""
371406

372407

@@ -395,6 +430,12 @@ def ones(
395430
-------
396431
out: array
397432
an array containing ones.
433+
434+
Notes
435+
-----
436+
437+
.. versionchanged:: 2022.12
438+
Added complex data type support.
398439
"""
399440

400441

@@ -420,6 +461,12 @@ def ones_like(
420461
-------
421462
out: array
422463
an array having the same shape as ``x`` and filled with ones.
464+
465+
Notes
466+
-----
467+
468+
.. versionchanged:: 2022.12
469+
Added complex data type support.
423470
"""
424471

425472

src/array_api_stubs/_2022_12/data_type_functions.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ def astype(x: array, dtype: dtype, /, *, copy: bool = True) -> array:
3636
-------
3737
out: array
3838
an array having the specified data type. The returned array must have the same shape as ``x``.
39+
40+
Notes
41+
-----
42+
43+
.. versionchanged:: 2022.12
44+
Added complex data type support.
3945
"""
4046

4147

@@ -97,6 +103,14 @@ def finfo(type: Union[dtype, array], /) -> finfo_object:
97103
- **dtype**: dtype
98104
99105
real-valued floating-point data type.
106+
107+
.. versionadded:: 2022.12
108+
109+
Notes
110+
-----
111+
112+
.. versionchanged:: 2022.12
113+
Added complex data type support.
100114
"""
101115

102116

@@ -129,6 +143,8 @@ def iinfo(type: Union[dtype, array], /) -> iinfo_object:
129143
- **dtype**: dtype
130144
131145
integer data type.
146+
147+
.. versionadded:: 2022.12
132148
"""
133149

134150

@@ -167,6 +183,11 @@ def isdtype(
167183
-------
168184
out: bool
169185
boolean indicating whether a provided dtype is of a specified data type kind.
186+
187+
Notes
188+
-----
189+
190+
.. versionadded:: 2022.12
170191
"""
171192

172193

0 commit comments

Comments
 (0)