Skip to content

Commit 3d91878

Browse files
steff456rgommers
andauthored
Add admonitions for new and changed APIs in 2022 version (#585)
- Add version changed to functions that were modified for complex support in 2022 - Add version added to functions created in 2022 Co-authored-by: Ralf Gommers <[email protected]>
1 parent 8d48911 commit 3d91878

12 files changed

+510
-2
lines changed

src/array_api_stubs/_draft/array_object.py

+67
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:
@@ -749,8 +785,14 @@ def __ne__(self: array, other: Union[int, float, bool, array], /) -> 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
751787
788+
Notes
789+
-----
790+
752791
.. note::
753792
Element-wise results, including special cases, must equal the results returned by the equivalent element-wise function :func:`~array_api.not_equal`.
793+
794+
.. versionchanged:: 2022.12
795+
Added complex data type support.
754796
"""
755797

756798
def __neg__(self: array, /) -> array:
@@ -773,9 +815,14 @@ def __neg__(self: array, /) -> array:
773815
out: array
774816
an array containing the evaluated result for each element in ``self``. The returned array must have a data type determined by :ref:`type-promotion`.
775817
818+
Notes
819+
-----
776820
777821
.. note::
778822
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.negative`.
823+
824+
.. versionchanged:: 2022.12
825+
Added complex data type support.
779826
"""
780827

781828
def __or__(self: array, other: Union[int, bool, array], /) -> array:
@@ -813,9 +860,14 @@ def __pos__(self: array, /) -> array:
813860
out: array
814861
an array containing the evaluated result for each element. The returned array must have the same data type as ``self``.
815862
863+
Notes
864+
-----
816865
817866
.. note::
818867
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.positive`.
868+
869+
.. versionchanged:: 2022.12
870+
Added complex data type support.
819871
"""
820872

821873
def __pow__(self: array, other: Union[int, float, array], /) -> array:
@@ -839,9 +891,14 @@ def __pow__(self: array, other: Union[int, float, array], /) -> array:
839891
out: array
840892
an array containing the element-wise results. The returned array must have a data type determined by :ref:`type-promotion`.
841893
894+
Notes
895+
-----
842896
843897
.. note::
844898
Element-wise results, including special cases, must equal the results returned by the equivalent element-wise function :func:`~array_api.pow`.
899+
900+
.. versionchanged:: 2022.12
901+
Added complex data type support.
845902
"""
846903

847904
def __rshift__(self: array, other: Union[int, array], /) -> array:
@@ -913,9 +970,14 @@ def __sub__(self: array, other: Union[int, float, array], /) -> array:
913970
out: array
914971
an array containing the element-wise differences. The returned array must have a data type determined by :ref:`type-promotion`.
915972
973+
Notes
974+
-----
916975
917976
.. note::
918977
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.subtract`.
978+
979+
.. versionchanged:: 2022.12
980+
Added complex data type support.
919981
"""
920982

921983
def __truediv__(self: array, other: Union[int, float, array], /) -> array:
@@ -939,9 +1001,14 @@ def __truediv__(self: array, other: Union[int, float, array], /) -> array:
9391001
out: array
9401002
an array containing the element-wise results. The returned array should have a floating-point data type determined by :ref:`type-promotion`.
9411003
1004+
Notes
1005+
-----
9421006
9431007
.. note::
9441008
Element-wise results, including special cases, must equal the results returned by the equivalent element-wise function :func:`~array_api.divide`.
1009+
1010+
.. versionchanged:: 2022.12
1011+
Added complex data type support.
9451012
"""
9461013

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

src/array_api_stubs/_draft/creation_functions.py

+47
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/_draft/data_type_functions.py

+21
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)