Skip to content

Commit 825cec7

Browse files
committed
add device kwarg to astype API
1 parent e72b3ca commit 825cec7

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/array_api_stubs/_draft/data_type_functions.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1-
from ._types import Union, Tuple, array, dtype, finfo_object, iinfo_object
2-
3-
4-
def astype(x: array, dtype: dtype, /, *, copy: bool = True) -> array:
1+
from ._types import (
2+
Union,
3+
Tuple,
4+
array,
5+
dtype,
6+
finfo_object,
7+
iinfo_object,
8+
device,
9+
Optional
10+
)
11+
12+
13+
def astype(
14+
x: array, dtype: dtype, /, *, copy: bool = True,
15+
device: Optional[device] = None
16+
) -> array:
517
"""
618
Copies an array to a specified data type irrespective of :ref:`type-promotion` rules.
719
@@ -31,6 +43,8 @@ def astype(x: array, dtype: dtype, /, *, copy: bool = True) -> array:
3143
desired data type.
3244
copy: bool
3345
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``.
46+
device: Optional[device]
47+
device on which to place the created array. Default: ``None``.
3448
3549
Returns
3650
-------

0 commit comments

Comments
 (0)