Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add device kwarg to astype API #665

Merged
merged 7 commits into from
Sep 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions src/array_api_stubs/_draft/data_type_functions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
from ._types import Union, Tuple, array, dtype, finfo_object, iinfo_object


def astype(x: array, dtype: dtype, /, *, copy: bool = True) -> array:
from ._types import (
Union,
Tuple,
array,
dtype,
finfo_object,
iinfo_object,
device,
Optional
)


def astype(
x: array, dtype: dtype, /, *, copy: bool = True,
device: Optional[device] = None
) -> array:
"""
Copies an array to a specified data type irrespective of :ref:`type-promotion` rules.

Expand Down Expand Up @@ -31,6 +43,8 @@ def astype(x: array, dtype: dtype, /, *, copy: bool = True) -> array:
desired data type.
copy: bool
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``.
device: Optional[device]
device on which to place the created array. Default: ``None``.
steff456 marked this conversation as resolved.
Show resolved Hide resolved

Returns
-------
Expand Down