Skip to content

Commit b080ded

Browse files
committed
Update the stubs for the latest version of the spec
1 parent 07390b4 commit b080ded

File tree

6 files changed

+27
-24
lines changed

6 files changed

+27
-24
lines changed

array_api_tests/function_stubs/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
__all__ = []
1111

12-
from .array_object import __abs__, __add__, __and__, __array_namespace__, __bool__, __dlpack__, __dlpack_device__, __eq__, __float__, __floordiv__, __ge__, __getitem__, __gt__, __index__, __int__, __invert__, __le__, __len__, __lshift__, __lt__, __matmul__, __mod__, __mul__, __ne__, __neg__, __or__, __pos__, __pow__, __rshift__, __setitem__, __sub__, __truediv__, __xor__, to_device, __iadd__, __radd__, __iand__, __rand__, __ifloordiv__, __rfloordiv__, __ilshift__, __rlshift__, __imatmul__, __rmatmul__, __imod__, __rmod__, __imul__, __rmul__, __ior__, __ror__, __ipow__, __rpow__, __irshift__, __rrshift__, __isub__, __rsub__, __itruediv__, __rtruediv__, __ixor__, __rxor__, dtype, device, mT, ndim, shape, size, T
12+
from .array_object import __abs__, __add__, __and__, __array_namespace__, __bool__, __dlpack__, __dlpack_device__, __eq__, __float__, __floordiv__, __ge__, __getitem__, __gt__, __index__, __int__, __invert__, __le__, __lshift__, __lt__, __matmul__, __mod__, __mul__, __ne__, __neg__, __or__, __pos__, __pow__, __rshift__, __setitem__, __sub__, __truediv__, __xor__, to_device, __iadd__, __radd__, __iand__, __rand__, __ifloordiv__, __rfloordiv__, __ilshift__, __rlshift__, __imatmul__, __rmatmul__, __imod__, __rmod__, __imul__, __rmul__, __ior__, __ror__, __ipow__, __rpow__, __irshift__, __rrshift__, __isub__, __rsub__, __itruediv__, __rtruediv__, __ixor__, __rxor__, dtype, device, mT, ndim, shape, size, T
1313

14-
__all__ += ['__abs__', '__add__', '__and__', '__array_namespace__', '__bool__', '__dlpack__', '__dlpack_device__', '__eq__', '__float__', '__floordiv__', '__ge__', '__getitem__', '__gt__', '__index__', '__int__', '__invert__', '__le__', '__len__', '__lshift__', '__lt__', '__matmul__', '__mod__', '__mul__', '__ne__', '__neg__', '__or__', '__pos__', '__pow__', '__rshift__', '__setitem__', '__sub__', '__truediv__', '__xor__', 'to_device', '__iadd__', '__radd__', '__iand__', '__rand__', '__ifloordiv__', '__rfloordiv__', '__ilshift__', '__rlshift__', '__imatmul__', '__rmatmul__', '__imod__', '__rmod__', '__imul__', '__rmul__', '__ior__', '__ror__', '__ipow__', '__rpow__', '__irshift__', '__rrshift__', '__isub__', '__rsub__', '__itruediv__', '__rtruediv__', '__ixor__', '__rxor__', 'dtype', 'device', 'mT', 'ndim', 'shape', 'size', 'T']
14+
__all__ += ['__abs__', '__add__', '__and__', '__array_namespace__', '__bool__', '__dlpack__', '__dlpack_device__', '__eq__', '__float__', '__floordiv__', '__ge__', '__getitem__', '__gt__', '__index__', '__int__', '__invert__', '__le__', '__lshift__', '__lt__', '__matmul__', '__mod__', '__mul__', '__ne__', '__neg__', '__or__', '__pos__', '__pow__', '__rshift__', '__setitem__', '__sub__', '__truediv__', '__xor__', 'to_device', '__iadd__', '__radd__', '__iand__', '__rand__', '__ifloordiv__', '__rfloordiv__', '__ilshift__', '__rlshift__', '__imatmul__', '__rmatmul__', '__imod__', '__rmod__', '__imul__', '__rmul__', '__ior__', '__ror__', '__ipow__', '__rpow__', '__irshift__', '__rrshift__', '__isub__', '__rsub__', '__itruediv__', '__rtruediv__', '__ixor__', '__rxor__', 'dtype', 'device', 'mT', 'ndim', 'shape', 'size', 'T']
1515

1616
from .constants import e, inf, nan, pi
1717

@@ -21,9 +21,9 @@
2121

2222
__all__ += ['arange', 'asarray', 'empty', 'empty_like', 'eye', 'from_dlpack', 'full', 'full_like', 'linspace', 'meshgrid', 'ones', 'ones_like', 'tril', 'triu', 'zeros', 'zeros_like']
2323

24-
from .data_type_functions import broadcast_arrays, broadcast_to, can_cast, finfo, iinfo, result_type
24+
from .data_type_functions import astype, broadcast_arrays, broadcast_to, can_cast, finfo, iinfo, result_type
2525

26-
__all__ += ['broadcast_arrays', 'broadcast_to', 'can_cast', 'finfo', 'iinfo', 'result_type']
26+
__all__ += ['astype', 'broadcast_arrays', 'broadcast_to', 'can_cast', 'finfo', 'iinfo', 'result_type']
2727

2828
from .elementwise_functions import abs, acos, acosh, add, asin, asinh, atan, atan2, atanh, bitwise_and, bitwise_left_shift, bitwise_invert, bitwise_or, bitwise_right_shift, bitwise_xor, ceil, cos, cosh, divide, equal, exp, expm1, floor, floor_divide, greater, greater_equal, isfinite, isinf, isnan, less, less_equal, log, log1p, log2, log10, logaddexp, logical_and, logical_not, logical_or, logical_xor, multiply, negative, not_equal, positive, pow, remainder, round, sign, sin, sinh, square, sqrt, subtract, tan, tanh, trunc
2929

@@ -41,9 +41,9 @@
4141

4242
__all__ += ['argmax', 'argmin', 'nonzero', 'where']
4343

44-
from .set_functions import unique
44+
from .set_functions import unique_all, unique_inverse, unique_values
4545

46-
__all__ += ['unique']
46+
__all__ += ['unique_all', 'unique_inverse', 'unique_values']
4747

4848
from .sorting_functions import argsort, sort
4949

array_api_tests/function_stubs/array_object.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,6 @@ def __le__(self: array, other: Union[int, float, array], /) -> array:
115115
"""
116116
pass
117117

118-
def __len__(self, /):
119-
"""
120-
Note: __len__ is a method of the array object.
121-
"""
122-
pass
123-
124118
def __lshift__(self: array, other: Union[int, array], /) -> array:
125119
"""
126120
Note: __lshift__ is a method of the array object.
@@ -211,7 +205,7 @@ def __xor__(self: array, other: Union[int, bool, array], /) -> array:
211205
"""
212206
pass
213207

214-
def to_device(self: array, device: device, /) -> array:
208+
def to_device(self: array, device: device, /, *, stream: Optional[Union[int, Any]] = None) -> array:
215209
"""
216210
Note: to_device is a method of the array object.
217211
"""
@@ -386,12 +380,12 @@ def __rxor__(self: array, other: Union[int, bool, array], /) -> array:
386380
ndim: int = None
387381

388382
# Note: shape is an attribute of the array object.
389-
shape: Union[Tuple[int, ...], shape] = None
383+
shape: Tuple[Optional[int], ...] = None
390384

391385
# Note: size is an attribute of the array object.
392-
size: int = None
386+
size: Optional[int] = None
393387

394388
# Note: T is an attribute of the array object.
395389
T: array = None
396390

397-
__all__ = ['__abs__', '__add__', '__and__', '__array_namespace__', '__bool__', '__dlpack__', '__dlpack_device__', '__eq__', '__float__', '__floordiv__', '__ge__', '__getitem__', '__gt__', '__index__', '__int__', '__invert__', '__le__', '__len__', '__lshift__', '__lt__', '__matmul__', '__mod__', '__mul__', '__ne__', '__neg__', '__or__', '__pos__', '__pow__', '__rshift__', '__setitem__', '__sub__', '__truediv__', '__xor__', 'to_device', '__iadd__', '__radd__', '__iand__', '__rand__', '__ifloordiv__', '__rfloordiv__', '__ilshift__', '__rlshift__', '__imatmul__', '__rmatmul__', '__imod__', '__rmod__', '__imul__', '__rmul__', '__ior__', '__ror__', '__ipow__', '__rpow__', '__irshift__', '__rrshift__', '__isub__', '__rsub__', '__itruediv__', '__rtruediv__', '__ixor__', '__rxor__', 'dtype', 'device', 'mT', 'ndim', 'shape', 'size', 'T']
391+
__all__ = ['__abs__', '__add__', '__and__', '__array_namespace__', '__bool__', '__dlpack__', '__dlpack_device__', '__eq__', '__float__', '__floordiv__', '__ge__', '__getitem__', '__gt__', '__index__', '__int__', '__invert__', '__le__', '__lshift__', '__lt__', '__matmul__', '__mod__', '__mul__', '__ne__', '__neg__', '__or__', '__pos__', '__pow__', '__rshift__', '__setitem__', '__sub__', '__truediv__', '__xor__', 'to_device', '__iadd__', '__radd__', '__iand__', '__rand__', '__ifloordiv__', '__rfloordiv__', '__ilshift__', '__rlshift__', '__imatmul__', '__rmatmul__', '__imod__', '__rmod__', '__imul__', '__rmul__', '__ior__', '__ror__', '__ipow__', '__rpow__', '__irshift__', '__rrshift__', '__isub__', '__rsub__', '__itruediv__', '__rtruediv__', '__ixor__', '__rxor__', 'dtype', 'device', 'mT', 'ndim', 'shape', 'size', 'T']

array_api_tests/function_stubs/creation_functions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
from __future__ import annotations
1212

13-
from ._types import (List, NestedSequence, Optional, SupportsBufferProtocol, SupportsDLPack, Tuple,
14-
Union, array, device, dtype)
13+
from ._types import (List, NestedSequence, Optional, SupportsBufferProtocol, Tuple, Union, array,
14+
device, dtype)
1515

1616
def arange(start: Union[int, float], /, stop: Optional[Union[int, float]] = None, step: Union[int, float] = 1, *, dtype: Optional[dtype] = None, device: Optional[device] = None) -> array:
1717
pass
1818

19-
def asarray(obj: Union[array, bool, int, float, NestedSequence[bool|int|float], SupportsDLPack, SupportsBufferProtocol], /, *, dtype: Optional[dtype] = None, device: Optional[device] = None, copy: Optional[bool] = None) -> array:
19+
def asarray(obj: Union[array, bool, int, float, NestedSequence[bool|int|float], SupportsBufferProtocol], /, *, dtype: Optional[dtype] = None, device: Optional[device] = None, copy: Optional[bool] = None) -> array:
2020
pass
2121

2222
def empty(shape: Union[int, Tuple[int, ...]], *, dtype: Optional[dtype] = None, device: Optional[device] = None) -> array:

array_api_tests/function_stubs/data_type_functions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
from ._types import List, Tuple, Union, array, dtype, finfo_object, iinfo_object
1414

15+
def astype(x: array, dtype: dtype, /, *, copy: bool = True) -> array:
16+
pass
17+
1518
def broadcast_arrays(*arrays: array) -> List[array]:
1619
pass
1720

@@ -30,4 +33,4 @@ def iinfo(type: Union[dtype, array], /) -> iinfo_object:
3033
def result_type(*arrays_and_dtypes: Union[array, dtype]) -> dtype:
3134
pass
3235

33-
__all__ = ['broadcast_arrays', 'broadcast_to', 'can_cast', 'finfo', 'iinfo', 'result_type']
36+
__all__ = ['astype', 'broadcast_arrays', 'broadcast_to', 'can_cast', 'finfo', 'iinfo', 'result_type']

array_api_tests/function_stubs/linalg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def slogdet(x: array, /) -> Tuple[array, array]:
6565
def solve(x1: array, x2: array, /) -> array:
6666
pass
6767

68-
def svd(x: array, /, *, full_matrices: bool = True) -> Tuple[array, array, array]:
68+
def svd(x: array, /, *, full_matrices: bool = True) -> Union[array, Tuple[array, ...]]:
6969
pass
7070

7171
def svdvals(x: array, /) -> array:

array_api_tests/function_stubs/set_functions.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@
1010

1111
from __future__ import annotations
1212

13-
from ._types import Tuple, Union, array
13+
from ._types import Tuple, array
1414

15-
def unique(x: array, /, *, return_counts: bool = False, return_index: bool = False, return_inverse: bool = False) -> Union[array, Tuple[array, ...]]:
15+
def unique_all(x: array, /) -> Tuple[array, array, array, array]:
1616
pass
1717

18-
__all__ = ['unique']
18+
def unique_inverse(x: array, /) -> Tuple[array, array]:
19+
pass
20+
21+
def unique_values(x: array, /) -> array:
22+
pass
23+
24+
__all__ = ['unique_all', 'unique_inverse', 'unique_values']

0 commit comments

Comments
 (0)