@@ -219,16 +219,15 @@ def astype(x, dtype, /, *, order="K", casting="unsafe", copy=True, device=None):
219219 Array data type casting.
220220 dtype : {None, str, dtype object}
221221 Target data type.
222- order : {'C', 'F', 'A', 'K'}
222+ order : {None, 'C', 'F', 'A', 'K'}, optional
223223 Row-major (C-style) or column-major (Fortran-style) order.
224- When `order` is ``A``, it uses ``F`` if `a` is column-major and uses
225- ``C`` otherwise. And when `order` is ``K``, it keeps strides as closely
226- as possible.
227- copy : bool
228- If it is ``False`` and no cast happens, then this method returns
229- the array itself. Otherwise, a copy is returned.
224+ When `order` is ``'A'``, it uses ``'F'`` if `a` is column-major and
225+ uses ``'C'`` otherwise. And when `order` is ``'K'``, it keeps strides
226+ as closely as possible.
227+
228+ Default: ``'K'``.
230229 casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
231- Controls what kind of data casting may occur. Defaults to ``unsafe``
230+ Controls what kind of data casting may occur. Defaults to ``' unsafe' ``
232231 for backwards compatibility.
233232
234233 - 'no' means the data types should not be cast at all.
@@ -238,24 +237,47 @@ def astype(x, dtype, /, *, order="K", casting="unsafe", copy=True, device=None):
238237 float64 to float32, are allowed.
239238 - 'unsafe' means any data conversions may be done.
240239
241- copy : {bool}, optional
242- By default, ``astype`` always returns a newly allocated array. If this
243- is set to ``False``, and the `dtype`, `order`, and `subok` requirements
244- are satisfied, the input array is returned instead of a copy.
240+ Default: ``'unsafe'``.
241+ copy : bool, optional
242+ Specifies whether to copy an array when the specified dtype matches the
243+ data type of the input array ``x``. If ``True``, a newly allocated
244+ array must always be returned. If ``False`` and the specified dtype
245+ matches the data type of the input array, the input array must be
246+ returned; otherwise, a newly allocated array must be returned.
247+
248+ Default: ``True``.
245249 device : {None, string, SyclDevice, SyclQueue}, optional
246- An array API concept of device where the output array is created.
247- The `device` can be ``None`` (the default), an OneAPI filter selector
248- string, an instance of :class:`dpctl.SyclDevice` corresponding to
249- a non-partitioned SYCL device, an instance of :class:`dpctl.SyclQueue`,
250- or a `Device` object returned by
251- :obj:`dpnp.dpnp_array.dpnp_array.device` property. Default: ``None``.
250+ An array API specification of device where the output array is created.
251+ Device can be specified by a filter selector string, an instance of
252+ :class:`dpctl.SyclDevice`, an instance of :class:`dpctl.SyclQueue`, or
253+ an instance of :class:`dpctl.tensor.Device`. If the value is ``None``,
254+ returned array is created on the same device as `x`.
255+
256+ Default: ``None``.
252257
253258 Returns
254259 -------
255- arr_t : dpnp.ndarray
256- Unless `copy` is ``False`` and the other conditions for returning
257- the input array are satisfied, `arr_t` is a new array of the same shape
258- as the input array, with dtype, order given by dtype, order.
260+ out : dpnp.ndarray
261+ An array having the specified data type.
262+
263+ See Also
264+ --------
265+ :obj:`dpnp.ndarray.astype` : Equivalent method.
266+
267+ Examples
268+ --------
269+ >>> import dpnp as np
270+ >>> x = np.array([1, 2, 3]); x
271+ array([1, 2, 3])
272+ >>> np.astype(x, np.float32)
273+ array([1., 2., 3.], dtype=float32)
274+
275+ Non-copy case:
276+
277+ >>> x = np.array([1, 2, 3])
278+ >>> result = np.astype(x, x.dtype, copy=False)
279+ >>> result is x
280+ True
259281
260282 """
261283
0 commit comments