You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- ``'integral'``: integer data types. Shorthand for ``('signed integer', 'unsigned integer')``.
49
+
- ``'real floating'``: real-valued floating-point data types (e.g., ``float32``, ``float64``).
50
+
- ``'complex floating'``: complex floating-point data types (e.g., ``complex64``, ``complex128``).
45
51
copy: bool
46
52
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
53
device: Optional[device]
@@ -50,7 +56,15 @@ def astype(
50
56
Returns
51
57
-------
52
58
out: array
53
-
an array having the specified data type. The returned array must have the same shape as ``x``.
59
+
For ``dtype_or_kind`` a data type, an array having the specified data type.
60
+
For ``dtype_or_kind`` a kind of data type:
61
+
- If ``x.dtype`` is already of that kind, the data type is maintained.
62
+
- Otherwise, an attempt is made to convert to the specified kind, according to the type promotion rules (see :ref:`type-promotion`).
63
+
- Numeric kinds are interpreted as the lowest-precision standard data type of that kind for the purposes of type promotion.
64
+
For example, ``astype(x, 'complex floating')`` will return an array with the data type ``complex64`` when ``x.dtype`` is ``float32``,
65
+
since ``complex64`` is the result of promoting ``float32`` with the lowest-precision standard complex data type, ``complex64``.
66
+
- For kind ``integral``, the 'lowest-precision standard data type' is interpreted as ``int8``, not ``uint8``.
67
+
The returned array must have the same shape as ``x``.
0 commit comments