Skip to content

Commit a7dd8ba

Browse files
authored
Update docstrings in indexing functions (#2307)
The PR proposes to implement documentation improvements, including: - correct example in `dpnp.select` - updates docstrings for indexing functions to have a blank line prior `Default` value - align description of `dtype` keyword across all functions Note, updates in other files with adding blank line prior `Default` will be covered separately.
1 parent 898b6f2 commit a7dd8ba

11 files changed

+138
-74
lines changed

dpnp/dpnp_algo/dpnp_elementwise_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ def outer(
411411
order : {None, "C", "F", "A", "K"}, optional
412412
Memory layout of the newly output array, Cannot be provided
413413
together with `out`. Default: ``"K"``.
414-
dtype : {None, dtype}, optional
414+
dtype : {None, str, dtype object}, optional
415415
If provided, the destination array will have this dtype. Cannot be
416416
provided together with `out`. Default: ``None``.
417417

dpnp/dpnp_array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ def astype(
791791
----------
792792
x1 : {dpnp.ndarray, usm_ndarray}
793793
Array data type casting.
794-
dtype : dtype
794+
dtype : {None, str, dtype object}
795795
Target data type.
796796
order : {"C", "F", "A", "K"}, optional
797797
Row-major (C-style) or column-major (Fortran-style) order.

dpnp/dpnp_iface.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def astype(x1, dtype, order="K", casting="unsafe", copy=True, device=None):
217217
----------
218218
x1 : {dpnp.ndarray, usm_ndarray}
219219
Array data type casting.
220-
dtype : dtype
220+
dtype : {None, str, dtype object}
221221
Target data type.
222222
order : {'C', 'F', 'A', 'K'}
223223
Row-major (C-style) or column-major (Fortran-style) order.
@@ -281,7 +281,7 @@ def as_usm_ndarray(a, dtype=None, device=None, usm_type=None, sycl_queue=None):
281281
----------
282282
a : {array_like, scalar}
283283
Input array or scalar.
284-
dtype : {None, dtype}, optional
284+
dtype : {None, str, dtype object}, optional
285285
The desired dtype for the result array if new array is creating. If not
286286
given, a default dtype will be used that can represent the values (by
287287
considering Promotion Type Rule and device capabilities when necessary).

dpnp/dpnp_iface_arraycreation.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def arange(
203203
step : {int, real}, optional
204204
Spacing between values. The default `step` size is 1. If `step`
205205
is specified as a position argument, `start` must also be given.
206-
dtype : {None, dtype}, optional
206+
dtype : {None, str, dtype object}, optional
207207
The desired dtype for the array. If not given, a default dtype will be
208208
used that can represent the values (by considering Promotion Type Rule
209209
and device capabilities when necessary).
@@ -306,7 +306,7 @@ def array(
306306
Input data, in any form that can be converted to an array. This
307307
includes scalars, lists, lists of tuples, tuples, tuples of tuples,
308308
tuples of lists, and ndarrays.
309-
dtype : {None, dtype}, optional
309+
dtype : {None, str, dtype object}, optional
310310
The desired dtype for the array. If not given, a default dtype will be
311311
used that can represent the values (by considering Promotion Type Rule
312312
and device capabilities when necessary).
@@ -462,7 +462,7 @@ def asanyarray(
462462
Input data, in any form that can be converted to an array. This
463463
includes scalars, lists, lists of tuples, tuples, tuples of tuples,
464464
tuples of lists, and ndarrays.
465-
dtype : {None, dtype}, optional
465+
dtype : {None, str, dtype object}, optional
466466
The desired dtype for the array. If not given, a default dtype will be
467467
used that can represent the values (by considering Promotion Type Rule
468468
and device capabilities when necessary).
@@ -565,7 +565,7 @@ def asarray(
565565
Input data, in any form that can be converted to an array. This
566566
includes scalars, lists, lists of tuples, tuples, tuples of tuples,
567567
tuples of lists, and ndarrays.
568-
dtype : {None, dtype}, optional
568+
dtype : {None, str, dtype object}, optional
569569
The desired dtype for the array. If not given, a default dtype will be
570570
used that can represent the values (by considering Promotion Type Rule
571571
and device capabilities when necessary).
@@ -670,7 +670,7 @@ def ascontiguousarray(
670670
Input data, in any form that can be converted to an array. This
671671
includes scalars, lists, lists of tuples, tuples, tuples of tuples,
672672
tuples of lists, and ndarrays.
673-
dtype : {None, dtype}, optional
673+
dtype : {None, str, dtype object}, optional
674674
The desired dtype for the array. If not given, a default dtype will be
675675
used that can represent the values (by considering Promotion Type Rule
676676
and device capabilities when necessary).
@@ -782,7 +782,7 @@ def asfortranarray(
782782
Input data, in any form that can be converted to an array. This
783783
includes scalars, lists, lists of tuples, tuples, tuples of tuples,
784784
tuples of lists, and ndarrays.
785-
dtype : {None, dtype}, optional
785+
dtype : {None, str, dtype object}, optional
786786
The desired dtype for the array. If not given, a default dtype will be
787787
used that can represent the values (by considering Promotion Type Rule
788788
and device capabilities when necessary).
@@ -1219,7 +1219,7 @@ def empty(
12191219
----------
12201220
shape : {int, sequence of ints}
12211221
Shape of the new array, e.g., (2, 3) or 2.
1222-
dtype : {None, dtype}, optional
1222+
dtype : {None, str, dtype object}, optional
12231223
The desired dtype for the array, e.g., dpnp.int32.
12241224
Default is the default floating point data type for the device where
12251225
input array is allocated.
@@ -1320,7 +1320,7 @@ def empty_like(
13201320
a : {dpnp.ndarray, usm_ndarray}
13211321
The shape and dtype of `a` define these same attributes
13221322
of the returned array.
1323-
dtype : {None, dtype}, optional
1323+
dtype : {None, str, dtype object}, optional
13241324
The desired dtype for the array, e.g., dpnp.int32.
13251325
Default is the default floating point data type for the device where
13261326
input array is allocated.
@@ -1433,7 +1433,7 @@ def eye(
14331433
Index of the diagonal: 0 (the default) refers to the main diagonal,
14341434
a positive value refers to an upper diagonal, and a negative value to
14351435
a lower diagonal.
1436-
dtype : {None, dtype}, optional
1436+
dtype : {None, str, dtype object}, optional
14371437
The desired dtype for the array, e.g., dpnp.int32.
14381438
Default is the default floating point data type for the device where
14391439
input array is allocated.
@@ -1541,7 +1541,7 @@ def frombuffer(
15411541
----------
15421542
buffer : buffer_like
15431543
An object that exposes the buffer interface.
1544-
dtype : data-type, optional
1544+
dtype : {None, str, dtype object}, optional
15451545
Data-type of the returned array.
15461546
Default is the default floating point data type for the device where
15471547
the returned array is allocated.
@@ -1646,7 +1646,7 @@ def fromfile(
16461646
----------
16471647
file : file or str or Path
16481648
Open file object or filename.
1649-
dtype : data-type, optional
1649+
dtype : {None, str, dtype object}, optional
16501650
Data type of the returned array.
16511651
For binary files, it is used to determine the size and byte-order
16521652
of the items in the file.
@@ -1779,7 +1779,7 @@ def fromfunction(
17791779
shape : (N,) tuple of ints
17801780
Shape of the output array, which also determines the shape of
17811781
the coordinate arrays passed to `function`.
1782-
dtype : data-type, optional
1782+
dtype : {None, str, dtype object}, optional
17831783
Data-type of the coordinate arrays passed to `function`.
17841784
Default is the default floating point data type for the device where
17851785
the returned array is allocated.
@@ -1887,7 +1887,7 @@ def fromiter(
18871887
----------
18881888
iter : iterable object
18891889
An iterable object providing data for the array.
1890-
dtype : data-type
1890+
dtype : {None, str, dtype object}
18911891
The data-type of the returned array.
18921892
count : int, optional
18931893
The number of items to read from *iterable*. The default is -1,
@@ -1981,7 +1981,7 @@ def fromstring(
19811981
----------
19821982
string : str
19831983
A string containing the data.
1984-
dtype : data-type, optional
1984+
dtype : {None, str, dtype object}, optional
19851985
The data type of the array.
19861986
For binary input data, the data must be in exactly this format.
19871987
Default is the default floating point data type for the device where
@@ -2159,7 +2159,7 @@ def full(
21592159
Fill value, in any form that can be converted to an array. This
21602160
includes scalars, lists, lists of tuples, tuples, tuples of tuples,
21612161
tuples of lists, and ndarrays.
2162-
dtype : {None, dtype}, optional
2162+
dtype : {None, str, dtype object}, optional
21632163
The desired dtype for the array, e.g., dpnp.int32.
21642164
Default is the default floating point data type for the device where
21652165
input array is allocated.
@@ -2263,7 +2263,7 @@ def full_like(
22632263
Fill value, in any form that can be converted to an array. This
22642264
includes scalars, lists, lists of tuples, tuples, tuples of tuples,
22652265
tuples of lists, and ndarrays.
2266-
dtype : {None, dtype}, optional
2266+
dtype : {None, str, dtype object}, optional
22672267
The desired dtype for the array, e.g., dpnp.int32.
22682268
Default is the default floating point data type for the device where
22692269
input array is allocated.
@@ -2382,7 +2382,7 @@ def geomspace(
23822382
num : int, optional
23832383
Number of samples to generate.
23842384
Default: ``50``.
2385-
dtype : {None, dtype}, optional
2385+
dtype : {None, str, dtype object}, optional
23862386
The desired dtype for the array. If not given, a default dtype will be
23872387
used that can represent the values (by considering Promotion Type Rule
23882388
and device capabilities when necessary).
@@ -2492,7 +2492,7 @@ def identity(
24922492
----------
24932493
n : int
24942494
Number of rows (and columns) in `n` x `n` output.
2495-
dtype : {None, dtype}, optional
2495+
dtype : {None, str, dtype object}, optional
24962496
The desired dtype for the array, e.g., dpnp.int32.
24972497
Default is the default floating point data type for the device where
24982498
input array is allocated.
@@ -2607,7 +2607,7 @@ def linspace(
26072607
of tuples, tuples of lists, and ndarrays. If `endpoint` is set to
26082608
``False`` the sequence consists of all but the last of ``num + 1``
26092609
evenly spaced samples, so that `stop` is excluded.
2610-
dtype : {None, dtype}, optional
2610+
dtype : {None, str, dtype object}, optional
26112611
The desired dtype for the array. If not given, a default dtype will be
26122612
used that can represent the values (by considering Promotion Type Rule
26132613
and device capabilities when necessary).
@@ -2716,7 +2716,7 @@ def loadtxt(
27162716
is ``.gz`` or ``.bz2``, the file is first decompressed. Note that
27172717
generators must return bytes or strings. The strings in a list or
27182718
produced by a generator are treated as lines.
2719-
dtype : data-type, optional
2719+
dtype : {None, str, dtype object}, optional
27202720
Data-type of the resulting array.
27212721
Default is the default floating point data type for the device where
27222722
the returned array is allocated.
@@ -2858,7 +2858,7 @@ def logspace(
28582858
The `step` size between the elements in ``ln(samples) / ln(base)``
28592859
(or log_base(samples)) is uniform.
28602860
Default: ``10.0``.
2861-
dtype : {None, dtype}, optional
2861+
dtype : {None, str, dtype object}, optional
28622862
The desired dtype for the array. If not given, a default dtype will be
28632863
used that can represent the values (by considering Promotion Type Rule
28642864
and device capabilities when necessary).
@@ -3196,7 +3196,7 @@ def ones(
31963196
----------
31973197
shape : {int, sequence of ints}
31983198
Shape of the new array, e.g., (2, 3) or 2.
3199-
dtype : {None, dtype}, optional
3199+
dtype : {None, str, dtype object}, optional
32003200
The desired dtype for the array, e.g., dpnp.int32.
32013201
Default is the default floating point data type for the device where
32023202
input array is allocated.
@@ -3303,7 +3303,7 @@ def ones_like(
33033303
a : {dpnp.ndarray, usm_ndarray}
33043304
The shape and dtype of `a` define these same attributes
33053305
of the returned array.
3306-
dtype : {None, dtype}, optional
3306+
dtype : {None, str, dtype object}, optional
33073307
The desired dtype for the array, e.g., dpnp.int32.
33083308
Default is the default floating point data type for the device where
33093309
input array is allocated.
@@ -3408,7 +3408,7 @@ def trace(a, offset=0, axis1=0, axis2=1, dtype=None, out=None):
34083408
Axes to be used as the first and second axis of the 2-D sub-arrays from
34093409
which the diagonals should be taken. Defaults are the first two axes of
34103410
`a`.
3411-
dtype : dtype, optional
3411+
dtype : {None, str, dtype object}, optional
34123412
Determines the data-type of the returned array and of the accumulator
34133413
where the elements are summed. If `dtype` has the value ``None`` and
34143414
`a` is of integer type of precision less than the default integer
@@ -3480,7 +3480,7 @@ def tri(
34803480
The sub-diagonal at and below which the array is filled. k = 0 is
34813481
the main diagonal, while k < 0 is below it, and k > 0 is above.
34823482
Default: ``0``.
3483-
dtype : {None, dtype}, optional
3483+
dtype : {None, str, dtype object}, optional
34843484
The desired dtype for the array, e.g., dpnp.int32.
34853485
Default is the default floating point data type for the device where
34863486
input array is allocated.
@@ -3841,7 +3841,7 @@ def zeros(
38413841
----------
38423842
shape : {int, sequence of ints}
38433843
Shape of the new array, e.g., (2, 3) or 2.
3844-
dtype : {None, dtype}, optional
3844+
dtype : {None, str, dtype object}, optional
38453845
The desired dtype for the array, e.g., `dpnp.int32`.
38463846
Default is the default floating point data type for the device where
38473847
input array is allocated.
@@ -3948,7 +3948,7 @@ def zeros_like(
39483948
a : {dpnp.ndarray, usm_ndarray}
39493949
The shape and dtype of `a` define these same attributes
39503950
of the returned array.
3951-
dtype : {None, dtype}, optional
3951+
dtype : {None, str, dtype object}, optional
39523952
The desired dtype for the array, e.g., dpnp.int32.
39533953
Default is the default floating point data type for the device where
39543954
input array is allocated.

0 commit comments

Comments
 (0)