Skip to content

Commit

Permalink
Merge pull request #665 from steff456/astype_device
Browse files Browse the repository at this point in the history
PR-URL: 	#665
Reviewed-by: Athan Reines <kgryte@gmail.com>
Reviewed-by: Olivier Grisel <olivier.grisel@ensta.org>
Reviewed-by: Leo Fang <leo80042@gmail.com>
  • Loading branch information
kgryte authored Sep 19, 2023
2 parents 39dd9ac + 1c6c73c commit d39fc66
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/array_api_stubs/_draft/data_type_functions.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
__all__ = ["astype", "can_cast", "finfo", "iinfo", "isdtype", "result_type"]


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 @@ -34,6 +44,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 returned array. If ``device`` is ``None``, the output array device must be inferred from ``x``. Default: ``None``.
Returns
-------
Expand Down

0 comments on commit d39fc66

Please sign in to comment.