Skip to content

Commit d39fc66

Browse files
authored
Merge pull request #665 from steff456/astype_device
PR-URL: #665 Reviewed-by: Athan Reines <[email protected]> Reviewed-by: Olivier Grisel <[email protected]> Reviewed-by: Leo Fang <[email protected]>
2 parents 39dd9ac + 1c6c73c commit d39fc66

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/array_api_stubs/_draft/data_type_functions.py

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
__all__ = ["astype", "can_cast", "finfo", "iinfo", "isdtype", "result_type"]
22

3-
4-
from ._types import Union, Tuple, array, dtype, finfo_object, iinfo_object
5-
6-
7-
def astype(x: array, dtype: dtype, /, *, copy: bool = True) -> array:
3+
from ._types import (
4+
Union,
5+
Tuple,
6+
array,
7+
dtype,
8+
finfo_object,
9+
iinfo_object,
10+
device,
11+
Optional,
12+
)
13+
14+
15+
def astype(
16+
x: array, dtype: dtype, /, *, copy: bool = True, device: Optional[device] = None
17+
) -> array:
818
"""
919
Copies an array to a specified data type irrespective of :ref:`type-promotion` rules.
1020
@@ -34,6 +44,8 @@ def astype(x: array, dtype: dtype, /, *, copy: bool = True) -> array:
3444
desired data type.
3545
copy: bool
3646
specifies whether to copy an array when the specified ``dtype`` matches the data type of the input array ``x``. If ``True``, a newly allocated array must always be returned. If ``False`` and the specified ``dtype`` matches the data type of the input array, the input array must be returned; otherwise, a newly allocated array must be returned. Default: ``True``.
47+
device: Optional[device]
48+
device on which to place the returned array. If ``device`` is ``None``, the output array device must be inferred from ``x``. Default: ``None``.
3749
3850
Returns
3951
-------

0 commit comments

Comments
 (0)