Skip to content

Commit 7fff293

Browse files
committed
Aligh docstring of astype method and function
1 parent 63089a4 commit 7fff293

File tree

2 files changed

+42
-42
lines changed

2 files changed

+42
-42
lines changed

dpnp/dpnp_array.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -789,33 +789,35 @@ def astype(
789789
790790
Parameters
791791
----------
792-
x1 : {dpnp.ndarray, usm_ndarray}
793-
Array data type casting.
794792
dtype : {None, str, dtype object}
795793
Target data type.
796-
order : {"C", "F", "A", "K"}, optional
794+
order : {None, "C", "F", "A", "K"}, optional
797795
Row-major (C-style) or column-major (Fortran-style) order.
798-
When ``order`` is 'A', it uses 'F' if ``a`` is column-major and uses 'C' otherwise.
799-
And when ``order`` is 'K', it keeps strides as closely as possible.
800-
copy : bool
801-
If it is False and no cast happens, then this method returns the array itself.
802-
Otherwise, a copy is returned.
803-
casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
804-
Controls what kind of data casting may occur.
805-
Defaults to ``'unsafe'`` for backwards compatibility.
806-
807-
- 'no' means the data types should not be cast at all.
808-
- 'equiv' means only byte-order changes are allowed.
809-
- 'safe' means only casts which can preserve values are allowed.
810-
- 'same_kind' means only safe casts or casts within a kind, like
811-
float64 to float32, are allowed.
812-
- 'unsafe' means any data conversions may be done.
813-
814-
copy : {bool}, optional
815-
By default, ``astype`` always returns a newly allocated array. If
816-
this is set to ``False``, and the `dtype`, `order`, and `subok`
817-
requirements are satisfied, the input array is returned instead of
818-
a copy.
796+
When `order` is ``"A"``, it uses ``"F"`` if `a` is column-major and
797+
uses ``"C"`` otherwise. And when `order` is ``"K"``, it keeps
798+
strides as closely as possible.
799+
800+
Default: ``"K"``.
801+
casting : {"no", "equiv", "safe", "same_kind", "unsafe"}, optional
802+
Controls what kind of data casting may occur. Defaults to
803+
``"unsafe"`` for backwards compatibility.
804+
805+
- "no" means the data types should not be cast at all.
806+
- "equiv" means only byte-order changes are allowed.
807+
- "safe" means only casts which can preserve values are allowed.
808+
- "same_kind" means only safe casts or casts within a kind,
809+
like float64 to float32, are allowed.
810+
- "unsafe" means any data conversions may be done.
811+
812+
Default: ``"unsafe"``.
813+
copy : bool, optional
814+
Specifies whether to copy an array when the specified dtype matches
815+
the data type of that array. If ``True``, a newly allocated array
816+
must always be returned. If ``False`` and the specified dtype
817+
matches the data type of that array, the self array must be returned;
818+
otherwise, a newly allocated array must be returned.
819+
820+
Default: ``True``.
819821
device : {None, string, SyclDevice, SyclQueue, Device}, optional
820822
An array API concept of device where the output array is created.
821823
`device` can be ``None``, a oneAPI filter selector string,
@@ -830,10 +832,8 @@ def astype(
830832
831833
Returns
832834
-------
833-
arr_t : dpnp.ndarray
834-
Unless `copy` is ``False`` and the other conditions for returning the input array
835-
are satisfied, `arr_t` is a new array of the same shape as the input array,
836-
with dtype, order given by dtype, order.
835+
out : dpnp.ndarray
836+
An array having the specified data type.
837837
838838
Limitations
839839
-----------
@@ -843,9 +843,9 @@ def astype(
843843
Examples
844844
--------
845845
>>> import dpnp as np
846-
>>> x = np.array([1, 2, 2.5])
847-
>>> x
846+
>>> x = np.array([1, 2, 2.5]); x
848847
array([1. , 2. , 2.5])
848+
849849
>>> x.astype(int)
850850
array([1, 2, 2])
851851

dpnp/dpnp_iface.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -220,25 +220,25 @@ def astype(x, dtype, /, *, order="K", casting="unsafe", copy=True, device=None):
220220
Array data type casting.
221221
dtype : {None, str, dtype object}
222222
Target data type.
223-
order : {None, 'C', 'F', 'A', 'K'}, optional
223+
order : {None, "C", "F", "A", "K"}, optional
224224
Row-major (C-style) or column-major (Fortran-style) order.
225-
When `order` is ``'A'``, it uses ``'F'`` if `a` is column-major and
226-
uses ``'C'`` otherwise. And when `order` is ``'K'``, it keeps strides
225+
When `order` is ``"A"``, it uses ``"F"`` if `a` is column-major and
226+
uses ``"C"`` otherwise. And when `order` is ``"K"``, it keeps strides
227227
as closely as possible.
228228
229-
Default: ``'K'``.
230-
casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
231-
Controls what kind of data casting may occur. Defaults to ``'unsafe'``
229+
Default: ``"K"``.
230+
casting : {"no", "equiv", "safe", "same_kind", "unsafe"}, optional
231+
Controls what kind of data casting may occur. Defaults to ``"unsafe"``
232232
for backwards compatibility.
233233
234-
- 'no' means the data types should not be cast at all.
235-
- 'equiv' means only byte-order changes are allowed.
236-
- 'safe' means only casts which can preserve values are allowed.
237-
- 'same_kind' means only safe casts or casts within a kind, like
234+
- "no" means the data types should not be cast at all.
235+
- "equiv" means only byte-order changes are allowed.
236+
- "safe" means only casts which can preserve values are allowed.
237+
- "same_kind" means only safe casts or casts within a kind, like
238238
float64 to float32, are allowed.
239-
- 'unsafe' means any data conversions may be done.
239+
- "unsafe" means any data conversions may be done.
240240
241-
Default: ``'unsafe'``.
241+
Default: ``"unsafe"``.
242242
copy : bool, optional
243243
Specifies whether to copy an array when the specified dtype matches the
244244
data type of the input array ``x``. If ``True``, a newly allocated

0 commit comments

Comments
 (0)