Skip to content

Commit 27b23f3

Browse files
committed
1 parent 58af424 commit 27b23f3

File tree

6 files changed

+27
-180
lines changed

6 files changed

+27
-180
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, 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', '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 & 166 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,168 +205,12 @@ 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
"""
218212
pass
219213

220-
def __iadd__(self: array, other: Union[int, float, array], /) -> array:
221-
"""
222-
Note: __iadd__ is a method of the array object.
223-
"""
224-
pass
225-
226-
def __radd__(self: array, other: Union[int, float, array], /) -> array:
227-
"""
228-
Note: __radd__ is a method of the array object.
229-
"""
230-
pass
231-
232-
def __iand__(self: array, other: Union[int, bool, array], /) -> array:
233-
"""
234-
Note: __iand__ is a method of the array object.
235-
"""
236-
pass
237-
238-
def __rand__(self: array, other: Union[int, bool, array], /) -> array:
239-
"""
240-
Note: __rand__ is a method of the array object.
241-
"""
242-
pass
243-
244-
def __ifloordiv__(self: array, other: Union[int, float, array], /) -> array:
245-
"""
246-
Note: __ifloordiv__ is a method of the array object.
247-
"""
248-
pass
249-
250-
def __rfloordiv__(self: array, other: Union[int, float, array], /) -> array:
251-
"""
252-
Note: __rfloordiv__ is a method of the array object.
253-
"""
254-
pass
255-
256-
def __ilshift__(self: array, other: Union[int, array], /) -> array:
257-
"""
258-
Note: __ilshift__ is a method of the array object.
259-
"""
260-
pass
261-
262-
def __rlshift__(self: array, other: Union[int, array], /) -> array:
263-
"""
264-
Note: __rlshift__ is a method of the array object.
265-
"""
266-
pass
267-
268-
def __imatmul__(self: array, other: array, /) -> array:
269-
"""
270-
Note: __imatmul__ is a method of the array object.
271-
"""
272-
pass
273-
274-
def __rmatmul__(self: array, other: array, /) -> array:
275-
"""
276-
Note: __rmatmul__ is a method of the array object.
277-
"""
278-
pass
279-
280-
def __imod__(self: array, other: Union[int, float, array], /) -> array:
281-
"""
282-
Note: __imod__ is a method of the array object.
283-
"""
284-
pass
285-
286-
def __rmod__(self: array, other: Union[int, float, array], /) -> array:
287-
"""
288-
Note: __rmod__ is a method of the array object.
289-
"""
290-
pass
291-
292-
def __imul__(self: array, other: Union[int, float, array], /) -> array:
293-
"""
294-
Note: __imul__ is a method of the array object.
295-
"""
296-
pass
297-
298-
def __rmul__(self: array, other: Union[int, float, array], /) -> array:
299-
"""
300-
Note: __rmul__ is a method of the array object.
301-
"""
302-
pass
303-
304-
def __ior__(self: array, other: Union[int, bool, array], /) -> array:
305-
"""
306-
Note: __ior__ is a method of the array object.
307-
"""
308-
pass
309-
310-
def __ror__(self: array, other: Union[int, bool, array], /) -> array:
311-
"""
312-
Note: __ror__ is a method of the array object.
313-
"""
314-
pass
315-
316-
def __ipow__(self: array, other: Union[int, float, array], /) -> array:
317-
"""
318-
Note: __ipow__ is a method of the array object.
319-
"""
320-
pass
321-
322-
def __rpow__(self: array, other: Union[int, float, array], /) -> array:
323-
"""
324-
Note: __rpow__ is a method of the array object.
325-
"""
326-
pass
327-
328-
def __irshift__(self: array, other: Union[int, array], /) -> array:
329-
"""
330-
Note: __irshift__ is a method of the array object.
331-
"""
332-
pass
333-
334-
def __rrshift__(self: array, other: Union[int, array], /) -> array:
335-
"""
336-
Note: __rrshift__ is a method of the array object.
337-
"""
338-
pass
339-
340-
def __isub__(self: array, other: Union[int, float, array], /) -> array:
341-
"""
342-
Note: __isub__ is a method of the array object.
343-
"""
344-
pass
345-
346-
def __rsub__(self: array, other: Union[int, float, array], /) -> array:
347-
"""
348-
Note: __rsub__ is a method of the array object.
349-
"""
350-
pass
351-
352-
def __itruediv__(self: array, other: Union[int, float, array], /) -> array:
353-
"""
354-
Note: __itruediv__ is a method of the array object.
355-
"""
356-
pass
357-
358-
def __rtruediv__(self: array, other: Union[int, float, array], /) -> array:
359-
"""
360-
Note: __rtruediv__ is a method of the array object.
361-
"""
362-
pass
363-
364-
def __ixor__(self: array, other: Union[int, bool, array], /) -> array:
365-
"""
366-
Note: __ixor__ is a method of the array object.
367-
"""
368-
pass
369-
370-
def __rxor__(self: array, other: Union[int, bool, array], /) -> array:
371-
"""
372-
Note: __rxor__ is a method of the array object.
373-
"""
374-
pass
375-
376214
# Note: dtype is an attribute of the array object.
377215
dtype: dtype = None
378216

@@ -386,12 +224,12 @@ def __rxor__(self: array, other: Union[int, bool, array], /) -> array:
386224
ndim: int = None
387225

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

391229
# Note: size is an attribute of the array object.
392-
size: int = None
230+
size: Optional[int] = None
393231

394232
# Note: T is an attribute of the array object.
395233
T: array = None
396234

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']
235+
__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', '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)